//symbol 为数据提供一个独一无二的值
{
let a1 =Symbol();
let a2 =Symbol();
//a1和a2永远都不会相等
console.log(a1===a2);//false
//但是另外一种方法可以
let a3 = Symbol.for('a3');
let a4 = Symbol.for('a3');
console.log(a3===a4);//true
//console.log(a3,a4);//是无法打印的
console.log('-----')
}
{
let a1=Symbol.for('abc');
let obj={
[a1]:'123',
'abcd':345,
'c':456,
};
console.log('obj',obj);
for (let [key,value] of Object.entries(obj)){
console.log('lot of', key,value);
}
Object.getOwnPropertySymbols(obj).forEach(function(item)){
console.log(obj,[item]);
}
//拿到了symbol和非symbol的值
Reflect.ownKeys(obj).forEach(function(item){
console.log('ownKeys',item,obj[item]);
})
}
console