// console.log(Math.round(Math.random()*80)); | |
// let sy = Symbol("key1"); | |
// let syObject = {}; | |
// syObject[sy] = "kk"; | |
// console.log(syObject[sy]); | |
// console.log(syObject.sy); | |
// let syObject = {}; | |
// syObject[sy] = "kk"; | |
// let obj = Object.getOwnPropertySymbols(syObject); | |
// console.log(syObject); | |
// let str={ | |
// name:"ww", | |
// id:1, | |
// age:18 | |
// } | |
// for (let i in syObject) { | |
// console.log(i); | |
// } | |
// let yellow = Symbol.for([1,'2',3]); | |
// let yellow1 = Symbol.for([1,2,3]); | |
// let yellow = Symbol.for({name:"张三",id:1}); | |
// let yellow1 = Symbol.for({name:"张三",id:1}); | |
// let obj = Object.getOwnPropertySymbols(Symbol.keyFor(yellow1)) | |
// console.log(yellow); | |
let yellow1 = Symbol.for({names:111,ids:'2',age:'2'}); | |
// console.log(yellow1); | |
console.log(Symbol.keyFor(yellow1));//"[object Object]" | |
console.log(typeof Symbol.keyFor(yellow1))//string | |
console.log(JSON.stringify(Symbol.keyFor(yellow1))); | |
// "[object Object]" | |
// map循环遍历 | |
let arr = [1,2,3,4,5]; | |
// for(let i=0;i<arr.length;i++){ | |
// arr[i] | |
// } | |
let str = [ | |
{ | |
id:1, | |
name:'张三', | |
age:18 | |
}, | |
{ | |
id:2, | |
name:'王五', | |
age:18 | |
}, | |
]; | |
// str.map(function(item,index){ | |
// console.log("item="+JSON.stringify(item)); | |
// console.log("index="+index); | |
// }) | |
str.map((item,index)=>{ | |
console.log(typeof item); | |
// item===Object | |
// console.log("item="+JSON.stringify(item)); | |
// console.log("index="+index); | |
}) |
Symbol用法和Map遍历
最新推荐文章于 2024-05-31 10:26:40 发布