当前位置:网站首页>JS get the attribute values nested in the object
JS get the attribute values nested in the object
2022-07-04 05:42:00 【_ Virgo programmer's daily life】
let data={
b:{
c:{
d:' study hard '
}
}
};
let arr = ['b','c','d'];
let result = arr.reduce((res,key)=>res[key],data)
console.log("result yes ");
console.log(result);// study hard
// Add , How to get arr Array
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] PivotChart
- VB. Net calls ffmpeg to simply process video (class Library-6)
- Nodejs learning document
- win10清除快速访问-不留下痕迹
- Arc135 C (the proof is not very clear)
- One click filtering to select Baidu online disk files
- px em rem的区别
- 509. Fibonacci number, all paths of climbing stairs, minimum cost of climbing stairs
- Integer type of C language
- js获取对象中嵌套的属性值
猜你喜欢
1480. Dynamic sum of one-dimensional array
C语言简易学生管理系统(含源码)
724. Find the central subscript of the array
VB.net 简单的处理图片,黑白(类库——7)
Principle and practice of common defects in RSA encryption application
Actual cases and optimization solutions of cloud native architecture
谷歌 Chrome 浏览器将支持选取文字翻译功能
[MySQL practice of massive data with high concurrency, high performance and high availability -8] - transaction isolation mechanism of InnoDB
Graduation design of small programs -- small programs of food and recipes
VB. Net simple processing pictures, black and white (class library - 7)
随机推荐
2022 a special equipment related management (elevator) examination questions simulation examination platform operation
Introduction to AMBA
JS flattened array of number shape structure
BUU-Crypto-[GUET-CTF2019]BabyRSA
Input displays the currently selected picture
win10清除快速访问-不留下痕迹
Just do it with your hands 7 - * project construction details 2 - hook configuration
724. Find the central subscript of the array
Halcon image calibration enables subsequent image processing to become the same as the template image
1480. Dynamic sum of one-dimensional array
Principle and practice of common defects in RSA encryption application
2022 question bank and answers for safety management personnel of hazardous chemical business units
tutle时钟改进版
BUU-Reverse-easyre
js如何将秒转换成时分秒显示
简易零钱通
Design and implementation of tcp/ip series overview
Arc135 C (the proof is not very clear)
VB. Net calls ffmpeg to simply process video (class Library-6)
How to use postman to realize simple interface Association [add, delete, modify and query]