What is the key difference between the || operator and the ?? operator in JavaScript?
The key difference between the || operator and the ?? (nullish coalescing) operator is that || returns the first truthy value, while ?? returns the first non-nullish value. A 'nullish' value is either null or undefined, but not other falsy values like 0, '', or false. For example, 0 || 'default' returns 'default' because 0 is falsy, but 0 ?? 'default' returns 0 because 0 is not nullish. This makes ?? more precise when you specifically want to provide defaults for null or undefined values, but not for other falsy values that might be valid in your context. The ?? operator was introduced in ECMAScript 2020 and is now widely supported in modern browsers.