JS Built-ins
← String190 / 195
StringString.prototype.valueOfbeginner

String.prototype.valueOf() β€” empty string valueOf

πŸ“– Usage Example
const str = 'Hello'
str.valueOf()               // β†’ 'Hello'
new String('hi').valueOf()   // β†’ 'hi'

Use valueOf() to return the primitive string value, useful when working with String wrapper objects.

String.prototype.valueOf() β€” Empty String

Calling valueOf() on an empty string returns an empty string.

Challenge: Implement emptyValueOf() that calls valueOf on an empty string.

emptyValueOf() // β†’ ''
πŸ’‘ Hints (1)
  • β€’ `"".valueOf()` returns `""` β€” the primitive empty string.