less Than Or Equal To Zero javascript 1

less Than Or Equal To Zero javascript

let string = "1";
let number = 1;
if (parseInt(string) === number){
  	// STRING AND NUMBER MATCHES
}
if (string == number){
  // STRING AND NUMBER MATCHES ALSO BECAUSE == instead of ===, means it won't compare datasets, only the content
}

Here is what the above code is Doing:
1. We have a string and a number with the same value.
2. We compare the string and the number using the === operator.
3. We compare the string and the number using the == operator.
4. The first comparison returns false because the === operator checks the data type of the values.
5. The second comparison returns true because the == operator doesn’t check the data type of the values.

Similar Posts