What is the output of the following? “`js const sym = Symbol(‘key’); const obj = { [sym]: 42, name: ‘test’ }; console.log(Object.keys(obj)); “`

JavaScript Developer Hard

JavaScript Developer — Hard

What is the output of the following? “`js const sym = Symbol(‘key’); const obj = { [sym]: 42, name: ‘test’ }; console.log(Object.keys(obj)); “`

Key points

  • `Object.keys()` does not include symbol properties.
  • The symbol property `[sym]` is not included in the output.
  • Only the property `'name'` is enumerable and will be returned.

Ready to go further?

Related questions