+ 1

What is difference in: (i=1),(i==1),(i===1) in java script ?

20th May 2017, 3:11 PM
GARG
GARG - avatar
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
20th May 2017, 3:19 PM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
+ 5
== also means identical to ?
20th May 2017, 3:18 PM
_Retr0/-
_Retr0/- - avatar
+ 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
20th May 2017, 3:17 PM
MR Programmer
MR Programmer - avatar
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
20th May 2017, 3:18 PM
Radek S
Radek S - avatar
0
If the two operands are of the same type and have the same value, then ===produces true
20th May 2017, 3:56 PM
Vishnu C Nair
Vishnu C Nair - avatar
0
Thanks
21st May 2017, 3:18 PM
GARG
GARG - avatar