Open BranceLee opened 6 years ago
const a=[1,2,2,3]
const a1={...a} //{0:1,1:2,2:2,3:3}
const b={name:"小强",age:17 }
const b1=Object.entries(b) //[["name,"小强"],["age",17]]
const key=Object.keys(b) //["name","age"]
cosnt value=Object.values(b) //["小强",17]
拓展:
Object.entries(Level).forEach(([level, config]) => { //顺带解构赋值了 const { getRoad, ipCord, ipDirection, targetCord } = config; })
并:
const U=new Set([...a1,...b1]) //
交:
const N=new Set([...a1].filter(x=>b1.has(x))) // 【...a1】转数组具有调filter ,
补:
const R=new Set([...a1].filter(x=>!b1.has(x)))