showing results for - "strict equality operator"
Erwann
31 Jul 2019
1// If you try to test if the number 5 
2//is equal to the string “5” the result is true. 
3var a = 5; 
4var b = "5"; 
5if ( a == b) --> true
6//That’s because JavaScript figures out the value 
7//of this string is five, and five is the same as five, 
8//so therefore a equals b.
9
10//But if you ever need to test to see 
11//if two things are identical, three symbols is the way to go. 
12var a = 5; 
13var b = "5"; 
14if ( a === b) --> false
Elena
31 Apr 2020
1//Strict equality operator
2
3console.log(1 === 1);
4// expected output: true
5
6console.log('hello' === 'hello');
7// expected output: true
8
9console.log('1' ===  1);
10// expected output: false
11
12console.log(0 === false);
13// expected output: false
14
15
16//Comparing operands of the same type
17
18console.log("hello" === "hello");   // true
19console.log("hello" === "hola");    // false
20
21console.log(3 === 3);               // true
22console.log(3 === 4);               // false
23
24console.log(true === true);         // true
25console.log(true === false);        // false
26
27console.log(null === null);         // true
28
29//Comparing operands of different types
30
31console.log("3" === 3);           // false
32
33console.log(true === 1);          // false
34
35console.log(null === undefined);  // false
36
37
38//Comparing objects
39
40const object1 = {
41  name: "hello"
42}
43
44const object2 = {
45  name: "hello"
46}
47
48console.log(object1 === object2);  // false
49console.log(object1 === object1);  // true
50
51//Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Strict_equality
Devin
06 Aug 2019
1/**
2* Strict equality operator (===) checks if its two operands are identical.
3*
4* The 'if' statement below will yield to false. 
5* 
6* This is because the strict equality operator checks if both the data type AND the value contained are
7* the same.
8*/
9let x = 8
10let y = "8"
11if (x === y)