Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6371665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:06:34+00:00 2026-05-25T01:06:34+00:00

Possible Duplicates: Javascript: undefined !== undefined? What is the best way to compare a

  • 0

Possible Duplicates:
Javascript: undefined !== undefined?
What is the best way to compare a value against 'undefined'?

I’ve played around with the console and got some strange results when checking undefined,
when I do var a; a‘s type and value become "undefined" right?
So why a===undefined is true and a=="undefined" or a==="undefined" are false?
and, would typeof a == "undefined" be the best practice like in other languages?

Unrelated – how do I markup code in a question from iPhone?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:06:35+00:00Added an answer on May 25, 2026 at 1:06 am

    When doing a==”undefined” or a===”undefined” you’re comparing the value of a with a string which contains the characters u, n, d, e, f, i, n, e, d.

    So your expression boils down to undefined==”somestring”, which is obviously false.

    typeof returns a string, so in this case comparing it to a string works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicates: Test for value in Javascript Array Best way to find an item
Possible Duplicates: Javascript - array.contains(obj) Best way to find an item in a JavaScript
Possible Duplicate: What is the best way to do loops in JavaScript What’s the
Possible Duplicates: Javascript closure inside loops - simple practical example Javascript closure “stores” value
Possible Duplicates: Is there a bignum library for JavaScript? Strange syntax of Number methods
Possible Duplicates: I am looking forward to call some javascript method from a java
Possible Duplicates: How does this JavaScript/JQuery Syntax work: (function( window, undefined ) { })(window)?
Possible Duplicates: Is there a way to access a javascript variable using a string
Possible Duplicates: JavaScript: Getting random value from an array How can I choose an
Possible Duplicate: Detecting an undefined object property in JavaScript From the below JavaScript sample,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.