JS Built-ins
Variablesbeginner

Variables β€” const: object properties are mutable

const prevents rebinding, not mutation

A const variable cannot be reassigned to a new value, but if it holds an object or array, you can still modify its properties/elements.

Challenge: Write constObject() that:

  1. Declares obj with const: { count: 0 }
  2. Sets obj.count = 42
  3. Returns obj.count
πŸ’‘ Hints (1)
  • β€’ const prevents reassigning the variable itself, not changing its properties