Tell us what’s happening:
Describe your issue in detail here.
1 != 2
1 != "1"
1 != '1'
1 != true
0 != false
In order, these expressions would evaluate to true , false , false , false , and false .
My issue is mentioned that thing in description , my according
1 != 2 → true
1 != “1” ->true(because “1” is string)
1 != ‘1’ ->true(coz ‘1’ is string)
1 != true ->true
0 != false → true
but in the description there is something else. Kindly clear my confusion.
**Your browser information:**
User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:89.0) Gecko/20100101 Firefox/89.0
Challenge: Comparison with the Inequality Operator
it can convert datatype while comparing isn’t it confusing then what is the point of comparison then? below lines are from description
" Like the equality operator, the inequality operator will convert data types of values while comparing."
I blame Microsoft jScript, circa 1996, when we didn’t know better. And now, with legacy code, we’re stuck with it.
There are a number of wonky things in javascript, often introduced in the early days before there was a standard. And many of them were quick to be adopted and used in production. At that point, we’re stuck with them. Mozilla will often list syntax parts as obsolete or discouraged, but they can’t really be removed.