let s:symbol = Symbol('测试')
let nums:symbol = Symbol(123)
console.log(s, nums) //Symbol(测试) Symbol(123)
let s1:symbol = Symbol(123)
let nums1:symbol = Symbol(123)
console.log(s1, nums1, s1 === nums1) // false 对应存储空间位置不一样 为false
let objxx = {
[nums1]: 'value',
[s]: "测试1",
name: '测试2',
sex: 'boy'
}
console.log(objxx)
for(let key in objxx) {
console.log(key) //只会打印出name sex
}
console.log(Object.keys(objxx)) //[ 'name', 'sex' ]
console.log(Object.getOwnPropertyNames(objxx)) //[ 'name', 'sex' ]
console.log(JSON.stringify(objxx)) //{"name":"测试2","sex":"boy"}
console.log(Object.getOwnPropertySymbols(objxx)) //[ Symbol(123), Symbol(测试) ]
console.log(Reflect.ownKeys(objxx)) //[ 'name', 'sex', Symbol(123), Symbol(测试) ]