Variables, Types, and Collections
23% of the examWhat this topic covers
Create and initialize variables, work with strings, numbers, and dates, and recognize how coercion and truthiness affect code. Manipulate arrays and JSON data, including handling date values and nullish fallbacks.
Does the nullish coalescing operator replace an empty string label?
No, the ?? operator supplies its fallback only when the label is null or undefined. An empty string is a valid label, so it stays as written. Use || only when you want every falsy value replaced, since it would also replace an empty string.