var jsonObject = { "name": "xiaoming", "age": 29 }, keys = []; for(var p in jsonObject){ keys.push(p); } console.log(keys)
var jsonObject1 = { "name": "xiaoming", "age": 29 }; var keys1 = []; for(var p1 in jsonObject1) { if(jsonObject1.hasOwnProperty(p1)) keys1.push(p1); } console.log(keys1); //name age
时间: 2024-11-06 11:37:29