+ 1
What is difference in: (i=1),(i==1),(i===1) in java script ?
6 Answers
+ 6
i=1 give 1 to i and return 1
i==1 return boolean (true/false)
i===1 retuen boolean (true/false)
differ:
i==1 if i is 1 or "1" return true
i===1 if i is 1 return true but if i is "1" return false
+ 5
== also means identical to ?
+ 4
i=1 means assigning i with value 1
i==1 is to check equal
i===1 is to check strictly equal
ex
var i=1;
console.log(i=='1');
// it will give true
console.log(i==='1');
// it will give you false
0
i=1 assign value, i==1 check if i is equal to 1, i ===1 check if i is equal 1 and if its Number type
0
If the two operands are of the same type and have the same value, then ===produces true
0
Thanks



