Are there (strict greater than) or (strict less than) comparison operators in JavaScript? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Are there (strict greater than) or (strict less than) comparison operators in JavaScript?

1st May 2020, 8:00 PM
Saeed Alqassabi
Saeed Alqassabi - avatar
4 Answers
+ 1
sorry if I said something wrong but I am not that much in JavaScript. like if i did : console.log("3" > 1); // true this is not strict as it seems, it doesn't return false. You know the strict equal to, right? like : console.log("3" === 3 ) // false so that if they are not from the same type it will return false.
1st May 2020, 8:45 PM
Saeed Alqassabi
Saeed Alqassabi - avatar
+ 1
Saeed Alqassabi JavaScript does not have that feature but you can check if two variables are of the same data type with "typeof" keyword console.log("3" > 1 && typeof "3" == typeof 1);
1st May 2020, 8:48 PM
Ore
Ore - avatar
+ 1
so there is no such a thing, but it looks too unhealthy to compare 2 different data types but it does the same as if they were from the same data type. so I have to check the data types first then if they are from the same type I will operate the comparison on them, and that is done using (typeof -data- ). thanks for the information.
1st May 2020, 8:58 PM
Saeed Alqassabi
Saeed Alqassabi - avatar
0
What do you mean by strict? The greater than and less than operators do what they are meant to do pretty well.
1st May 2020, 8:26 PM
Ore
Ore - avatar