The difference between the == and === operators in JavaScript
In JavaScript, the == and === operators are used to compare between two operands.
The == operator abstracts, that is, it makes the necessary type conversions before comparing the equality. Syntax of comparison: a == b .
The === operator compares strict equality, meaning that it will not perform type conversions. So if two values are not of the same type, then when compared, the result will return false. Syntax of comparison: a === b .

Example 1:
Output:
true false
Example 2:
Output:
true false
Example 3:
Output:
true false
In general, the === operator is recommended because it never performs type conversions when making comparisons, so it always produces accurate results.
Readers can learn more about other operators in the article: Operators in JavaScript.
5 ★ | 1 Vote
You should read it
May be interested
- What is TypeScript? How to install TypeScript?languages that use static variables can provide more stability and reduce errors in code. typescript narrows the gap between javascript and traditional programming rules.
- Object Number in JavaScriptthe number object represents the date in the form of a numeric value, or an integer or floating-point number. generally, you don't need to worry about number objects because the browser automatically converts number literals to illustrate the number classes.
- Boolean objects in JavaScriptboolean objects represent two values, either true or false. if the value parameter is omitted either 0, -0, null, false, nan, undefined, or an empty string (), the object has an initial value of false.
- String object in JavaScriptthe string object helps you work with a series of characters; it helps handle the original string data types in javascript with some help methods.
- Array (Array) in JavaScriptarray object - array helps you store multiple values in a single variable. it stores a set of fixed-size ranges of elements in the same type (type). an array is used to store a data set, but it is often more useful to think of an array as a collection of variables in the same type.
- Date object in JavaScriptdate object is a data type built into javascript language.