What are the primitive data types in JavaScript, and how do they behave?
The seven JavaScript primitive types in practice: coercion, equality, NaN, bigint, null versus undefined, falsy values, and common pitfalls to avoid.
Spread Your Knowledge. Questions with answers, tutorials and articles, newest first.
The seven JavaScript primitive types in practice: coercion, equality, NaN, bigint, null versus undefined, falsy values, and common pitfalls to avoid.
R has no === operator. Learn the R equivalents, == and identical(), plus how to compare floating-point numbers safely with all.equal().
== is JavaScript's loose equality operator: it converts types before comparing. See the conversion rules, the odd results, and when === is safer.
Use === by default because it never converts types. Learn how == coercion works, the one safe use of == null, and common pitfalls.
Java's == compares references while equals() compares content. See string pool and Integer cache pitfalls, plus a note on JavaScript.
There is no === in C: using it is a syntax error. See how == works, implicit conversions, and common equality pitfalls.
The == and != operators compare values in Python, while is compares identity. See how they treat types, floats, containers and custom classes.
=!? is not a real operator. Here is how JavaScript parses =! and ?, and which comparison operators you probably meant.
The !== operator returns true when two values differ in type or value, with no type coercion. See how it compares with !=, === and == in JavaScript, TypeScript and PHP.
!== in React is the JavaScript strict inequality operator. See how it drives conditional rendering, list filtering and memoisation behaviour.
=== checks type and value with no coercion, while <= compares numbers or strings after conversion. See how each behaves with NaN, strings and objects.
!= compares after type coercion while !== compares value and type strictly. See the coercion rules, edge cases, and which operator to use.
Java has no strict equality operator. Use == for primitives and enums, and equals() for objects, with null-safe and floating-point rules.
== compares after type coercion; === compares type and value. Learn the rules, the surprising results and which operator to use.
JavaScript compares values with equality and relational operators. Learn how == differs from ===, why there is no <> or ><, and how to avoid common bugs.
The == operator is JavaScript loose equality: it converts types before comparing. Learn how it works, its surprises and when to use === instead.
Strict equality (===) is the safe default in JavaScript. See how loose equality coerces types, the one accepted exception and how to enforce the rule.
For objects, == and === both compare references, so equal-looking objects are never equal. Learn the exceptions and how to compare contents.
!== is JavaScript strict inequality. It returns true when two values differ in type or value, with no type coercion. See examples and pitfalls.
The === operator returns true only when both operands have the same type and value. Learn how it differs from == and how it handles NaN and objects.