一 Reflect.ownKeys()
let fruit = { ‘2‘ : ‘mango‘, [Symbol.for(‘pink‘)] : ‘peach‘, ‘red‘ : ‘apple‘, ‘yellow‘ : ‘banana‘, [Symbol.for(‘purple‘)] : ‘grape‘, ‘1‘ : ‘Litchi‘ }; console.log(‘Reflect.ownKeys‘,Reflect.ownKeys(fruit)); console.log(‘Object.getOwnPropertyNames‘,Object.getOwnPropertyNames(fruit)); console.log(‘Object.getOwnPropertySymbols‘,Object.getOwnPropertySymbols(fruit)); console.log(Object.getOwnPropertyNames(fruit).concat(Object.getOwnPropertySymbols(fruit)));
时间: 2024-10-20 14:24:03