标签:names cti values code key -- class reac pre
//方法1
let persion = { name:‘json‘, age:18, adress:‘ftq‘ } for( a[a.length] in persion){console.log(a)}
//
["name"]
["name", "age"]
["name", "age", "adress"]
let c = [];let d = [] let persion3 = { name:‘json‘, age:18, adress:‘ftq‘ } for( c in persion3){ d = persion3[c] ;console.log(c,d)} //name json // age 18
// adress ftq
//方法2
const obj = { name:‘json‘, age:18 } console.log(Object.keys(obj)) // ["name", "age"] console.log(Object.values(obj))//["json", 18"]
//方法3
const obj2 = { name:‘json‘, age:18 } Object.getOwnPropertyNames(obj2).forEach(function(key){ console.log(key+ ‘---‘+obj[key]) }) //name---json age---18
标签:names cti values code key -- class reac pre
原文地址:https://www.cnblogs.com/maoyizhimi/p/14252078.html