JS Built-ins
ObjectObjectbeginner

Object(undefined) β€” returns empty object

πŸ“– Usage Example
// Wrap a value in an Object wrapper
const obj = new Object(42)
typeof obj   // β†’ 'object'
obj.valueOf()  // β†’ 42

Use the Object constructor to explicitly wrap a primitive value in an object.

Object(undefined)

Like Object(null), passing undefined to Object() returns a new empty object.

Challenge: Implement fromUndefined() that calls Object(undefined) and returns it.

fromUndefined() // β†’ {}
πŸ’‘ Hints (2)
  • β€’ `Object(undefined)` behaves exactly like `new Object()` or `{}`.
  • β€’ This is consistent with `Object(null)` β€” both nullish values produce `{}`.