当前位置:网站首页>JS get the key and value of the object

JS get the key and value of the object

2022-07-07 23:20:00 Blue fatty's Dora A Dream

js Get the object's key and value

Get the object's keys Array :Object.keys(obj)
Get the object's values Array :Object.values(obj)

let obj = {
    
  name: ' Zhang San ',
  age: 30,
  sex: ' male '
}
console.log(obj)
console.log(Object.keys(obj))
console.log(Object.values(obj))

 Insert picture description here
obtain keys One of the first : Object.keys(obj)[0] // name

原网站

版权声明
本文为[Blue fatty's Dora A Dream]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207072033232675.html