let arr=["sd","ha"];
let obj=Object.entries(arr);
console.log(obj);
for (const iterator of arr) {
    console.log(iterator);
}
for (const iterator of obj) {
    console.log(iterator);
}
for (const [k,v] of obj) {
    console.log(k,v);
}

const user={
    name:"hundsun",
    age:16
}

console.log(
    //getOwnPropertyDescriptor
    JSON.stringify(Object.getOwnPropertyDescriptor(user,"name"),null,2)
);

console.log(
    //getOwnPropertyDescriptors
    JSON.stringify(Object.getOwnPropertyDescriptors(user),null,2)
);


/*
  "value": "hundsun",
  "writable": true,
  "enumerable": true,
  "configurable": true
}
axioshtml.html:548 {
  "name": {
    "value": "hundsun",
    "writable": true,
    "enumerable": true,
    "configurable": true
  },
  "age": {
    "value": 16,
    "writable": true,
    "enumerable": true,
    "configurable": true
  }
}
*/

 

posted on 2022-01-22 21:06  weakup  阅读(15)  评论(0编辑  收藏  举报