JS Built-ins
ObjectObjectbeginner

Object(null) β€” 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(null) and Object(undefined)

Calling Object(null) or Object(undefined) does not throw β€” it returns a new empty plain object {}.

Challenge: Implement fromNull() that calls Object(null) and returns the result.

fromNull() // β†’ {}
πŸ’‘ Hints (2)
  • β€’ `Object(null)` safely returns `{}` β€” it does not throw.
  • β€’ Both `null` and `undefined` produce an empty plain object when passed to `Object()`.