Compare values

2 snippets across 2 stacks — JavaScript, SQL

JSJavaScript

Equality: == vs === vs Object.is

JS · Data Types
syntax
a === b   // strict (no coercion)
a == b    // loose (with coercion)
Object.is(a, b)  // same-value equality
example
console.log(0 == false);         // true
console.log(0 === false);        // false
console.log(NaN === NaN);        // false
console.log(Object.is(NaN, NaN)); // true
console.log(Object.is(0, -0));    // false

Note Always use === for comparisons. Object.is() handles edge cases like NaN and -0 that even === gets wrong.

SQLSQL

Comparison Operators

SQL · Filtering
syntax
WHERE column = | <> | < | > | <= | >= value
example
SELECT product_name, price
FROM products
WHERE price >= 50.00 AND price < 200.00;
output
-- Products priced from 50 up to (not including) 200

Note Use <> for not-equal (ANSI standard). != works in MySQL and PostgreSQL but is not part of the standard.