Why we use exclamatory(!!) sign and double equal (==) ?? Plz explain!! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why we use exclamatory(!!) sign and double equal (==) ?? Plz explain!!

if(n1.value != '' && n2.value != '') { if(n1.value == n2.value) }

17th Nov 2016, 5:35 PM
Infoore
Infoore - avatar
3 Answers
+ 1
The exclamation mark simply means "not", while double equal is to check for "equality". Basically, this code is checking if n1.value is not an empty string and if n2.value is not an empty string in the first if statement; while in the second if statement, it's checking if n1.value is equal to n2.value
17th Nov 2016, 5:54 PM
Victor Ogudu
Victor Ogudu - avatar
0
thanks bro, what about '&&' sign? why it is used in javascript??
17th Nov 2016, 5:59 PM
Infoore
Infoore - avatar
0
The '&&' sign is used to check if both values on left and right sides of the sign are true. It is known as the 'logical and' sign
17th Nov 2016, 6:04 PM
Victor Ogudu
Victor Ogudu - avatar