JS对象键值对应

创建初始化一个对象做例子

var person = {
    "name": "gongao",
    "sex": "man",
    "age": "23"
}//object

遍历key(键)

for ( let key in person)
{
     console.log(key)
}//  name sex age

遍历value(值)

for (let key in person)
{
  console.log(person[key])
}// gongao man 23

你可能感兴趣的:(JS对象键值对应)