Q:

string comparison in 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
}
0
console.log("10" == 10); //True
console.log(parseInt(10) == 10); // True Best practice
0
// Operator / Description
	==		// equal to
	===		// equal value and equal type
	!=		// not equal		
	!==		// not equal value or not equal type	
	>		// greater than	
	<		// less than	
	>=		// greater than or equal to	
	<=		// less than or equal to
0

New to Communities?

Join the community