JS Built-ins
← String192 / 195
StringString.prototype.lengthbeginner

String.prototype.length β€” empty string length 0

πŸ“– Usage Example
'hello'.length    // β†’ 5
''.length         // β†’ 0
'πŸ˜€'.length       // β†’ 2

The length property returns the number of UTF-16 code units in the string.

String.prototype.length β€” Empty String

An empty string '' has a length of 0.

Challenge: Implement isEmpty(str) that returns true if the string has length 0.

isEmpty('')      // β†’ true
isEmpty('hello') // β†’ false
πŸ’‘ Hints (1)
  • β€’ `"".length === 0` is always `true`.