Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

251
Views
Is there an operator for comparing undefined or null types?

Sorry if the title made it unclear, but I've been wondering, is there an operator for comparing types like null and "null"?
We all know that:
"1" == 1 returns true.
and
"1" === 1 returns false.
But when I try to do something like:
undefined == "undefined", for me, it returns false, even though I am not using ===.
Why does this occur? Is there an operator for comparing undefined and "undefined", or null and "null"?, etc...

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

In answer to the question in the title, no there isn't - JavaScript does not generally examine the semantic content of strings - "use strict" placed at the beginning of code to invoke strict mode execution is the exeception.

Note that the typeof operator is a convenience operator which does not return the data type of its operand in all cases - function objects are of (JavaScript) data type "Object", and null is of (JavaScript) data type "Null".

"undefined" is a string value with specific content. It is not equal to undefined (the one and only value with data type "Undefined") or null (the one and only value with data type "Null").

There is however an automatic type conversion between null and undefined which causes the non-strict equality operator to treat them as being equal, often used with a negation operator:

 if( value != null) {
     // proceed knowing value isn't `undefined` or `null
 }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!