bhylu.com

Advertisements

JS Logical

Logical operators combine conditions or choose fallback values. Nullish coalescing falls back only for null or undefined.

Where to run this

This example uses the JavaScript console playground. Select Run to execute it; the example does not run on this lesson page.

A practical example

JavaScript

const supplied = 0;
const count = supplied ?? 10;
console.log(count);
console.log(count >= 0 && count <= 20);

What happens

The zero is preserved and the range check is true.