!= vs !== javascript code example

Example 1: != vs !== javascript

(0 ==  '0') // true
(0 === '0') // false

('' ==  0 ) // true, the string will implicitly be converted to an integer
('' === 0 ) // false, no implicit cast is being made

Example 2: javascript == vs ===

var one = 1;
var one_again = 1;
var one_string = "1";  // note: this is string

console.log(one ==  one_again);  // true
console.log(one === one_again);  // true
console.log(one ==  one_string); // true. 
console.log(one === one_string); // false.

Example 3: == vs === javascript

== Equal to (1 == 1, 1 == "1") // equal in value ("1" is a string)
=== Equal value and equal type (1 === 1 but, 1 !== "1" // not equal type

Example 4: javascript !! vs !

// !! used for checking availability of data 
!!'hello' // true