==
and !=
JS-0050 24socket.on('signup',async (data)=>{
25 try{
26 let result = await userController.signup_user(data.name,data.password,socket.id);
27 if(result=="Name is taken"){ 28 socket.emit('nameerr',result);
29 return;
30 }
44 try{
45 let result = await userController.login_user(data.name,data.password,socket.id);
46
47 if(result=="Auth failed"){ 48 socket.emit('autherr',result);
49 return;
50 }
77
78 let rooms = await userController.get_rooms(data.sendby);
79 for(let r of rooms.rooms){
80 if(r==(data.sendto+data.sendby+"Room")||r==(data.sendby+data.sendto+"Room")){ 81 room = r;
82 break;
83 }
77
78 let rooms = await userController.get_rooms(data.sendby);
79 for(let r of rooms.rooms){
80 if(r==(data.sendto+data.sendby+"Room")||r==(data.sendby+data.sendto+"Room")){ 81 room = r;
82 break;
83 }
116 let rooms = await userController.get_rooms(data.sendby);
117 let room;
118 for(let r of rooms.rooms){
119 if(r==(data.sendto+data.sendby+"Room")||r==(data.sendby+data.sendto+"Room")){120 room = r;
121 break;
122 }
It is considered good practice to use the type-safe equality operators ===
and !==
instead of their regular counterparts ==
and !=
.
The strict equality operators (===
and !==
) use the strict equality comparison algorithm to compare two operands.
false
.true
only if they refer to the same object.null
or both operands are undefined
, return true
.NaN
, return false
.+0
and -0
are considered to be the same value.true
or both false
.The most notable difference between this operator and the equality (==
) operator is that if the operands are of different types, the ==
operator attempts to convert them to the same type before comparing.
a == b
foo == true
bananas != 1
value == undefined
typeof foo == 'undefined'
'hello' != 'world'
0 == 0
true == true
foo == null
a === b
foo === true
bananas !== 1
value === undefined
typeof foo === 'undefined'
'hello' !== 'world'
0 === 0
true === true
foo === null