当前位置:网站首页>js获取对象中嵌套的属性值
js获取对象中嵌套的属性值
2022-07-04 05:29:00 【_处女座程序员的日常】
let data={
b:{
c:{
d:'好好学习'
}
}
};
let arr = ['b','c','d'];
let result = arr.reduce((res,key)=>res[key],data)
console.log("result是");
console.log(result);// 好好学习
// 补充,如何获取arr数组
getKeys(value){
console.log(Object.keys(value)[0])
if(typeof value =='string') return;
this.arr.push(Object.keys(value)[0]);
this.getKeys (value[Object.keys(value)[0]])
},
边栏推荐
- Excel comparator
- How to configure static IP for Kali virtual machine
- [matlab] matlab simulates digital bandpass transmission system ask, PSK, FSK system
- 基于单片机的太阳能杀虫系统
- JS string splicing
- C语言简易学生管理系统(含源码)
- IP时代来临,电竞酒店如何借好游戏的“东风”?
- Appearance of LabVIEW error dialog box
- LabVIEW错误对话框的出现
- C language simple student management system (including source code)
猜你喜欢
transformer坑了多少算力
Programming example of stm32f1 and stm32subeide -74hc595 drives 4-bit 7-segment nixie tube
How to configure static IP for Kali virtual machine
Trie number dictionary tree
The data mark is a piece of fat meat, and it is not only China Manfu technology that focuses on this meat
June 2022 summary
TCP state transition diagram
云原生架构实战案例及优化解决方案
Topological sorting and graphical display of critical path
Simulink and Arduino serial port communication
随机推荐
left_and_right_net正常版本
Overview of relevant subclasses of beanfactorypostprocessor and beanpostprocessor
RSA加密应用常见缺陷的原理与实践
How to configure static IP for Kali virtual machine
Viewing and using binary log of MySQL
PostgreSQL has officially surpassed mysql. Is this guy too strong!
Notepad++--显示相关的配置
Wechat applet +php realizes authorized login
Signification des lettres du module optique et abréviation des paramètres Daquan
c语言经典指针和数组笔试题解析
Redis realizes ranking function
BUU-Crypto-Cipher
How to clone objects
基于单片机的太阳能杀虫系统
Flutter calls Gaode map app to realize location search, route planning and reverse geocoding
transformer坑了多少算力
FreeRTOS 中 RISC-V-Qemu-virt_GCC 的 锁机制 分析
ping端口神器psping
Principle and practice of common defects in RSA encryption application
Leetcode 184 Employees with the highest wages in the Department (July 3, 2022)