JavaScript less than or equals (bool <= int) [duplicate] - javascript

This question already has an answer here:
How do the JavaScript relational comparison operators coerce types?
(1 answer)
Closed 8 years ago.
I am wondering if anyone can explain the behavious of comparison operators when using booleans and integers.
Why do the following statements produce the results they do?
false < = 9 // true
false >= 9 // false
Thanks

The representation of false in memory is 0. That's why you obtain those results.

Related

Javascript: null==0 returns false, but null<1 returns true. Please explain [duplicate]

This question already has answers here:
Why is null in JavaScript bigger than -1, less than 1, but not equal (==) to 0? What is it exactly then?
(2 answers)
Closed 2 years ago.
very weird behaviour indeed.
Please explain the implicit conversions that happen in each case.
null will be converted to the number 0 (because < works with numbers), and 0 is less than 1.

How NaN==NaN returns false? [duplicate]

This question already has answers here:
What is the intuitive reason that NaN != NaN?
(1 answer)
Why is NaN === NaN false? [duplicate]
(3 answers)
Closed 4 years ago.
NaN==NaN
returns false in javascripts. i want to know some clear explanation.
typeof NaN is number
Number == Number is return true
Then why NaN==NaN is false. Thanks advance.

Plus operator in javascript [duplicate]

This question already has answers here:
What is the purpose of a plus symbol before a variable?
(4 answers)
Closed 6 years ago.
What does if (t == +t) { ... } mean?
Sorry for asking such a simple question, but I have searched for "plus operator" and tried to evaluate it in javascript myself, but I cannot guess what the purpose is.
Its a unary operator and it coerces t to a number from a string. It has the same effect as:
if (t == Number(t)) { ... }
For more information: Is plus sign in +process a typo in Node.js documentation on domains?

What logic is behind NaN evaluation? [duplicate]

This question already has answers here:
Why is NaN === NaN false? [duplicate]
(3 answers)
Closed 8 years ago.
Can you explain the logical evaluation of NaN in javascript?
NaN==NaN (false)
!NaN==!NaN (true)
NaN!=NaN (true)
NaN==false (false)
NaN==true (false)
I am a little surprised here...
Because that's what the spec says.
Specifically, the IEE floating point spec says that NaN does not equal itself.
Therefore, in Javascript, there is no value that NaN can ever equal.
!NaN is true, because NaN is a falsy value.
This makes all of your examples obvious.

Difference between "==" and "===" in java script [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Javascript === vs == : Does it matter which “equal” operator I use?
Hi
I am not clear why there are two == and === comparator operators in java script.
The equality operator == coerces, or converts the data type temporarily to see if it's equal to the other operand whereas the identity operator === doesn't need to do any converting whatsoever since it directly compares them without conversion meaning it's stricter and faster.
2=='2'
true
2==='2'
false

Categories

Resources