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 8783747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:54:18+00:00 2026-06-13T20:54:18+00:00

Basically two questions, both pertaining to the behavior of undefined . Q1 Why is

  • 0

Basically two questions, both pertaining to the behavior of undefined.

Q1 Why is it that this fails with a reference error:

function hello(a){
      return true;  
      }  
//var abc = undefined;
hello(abc);

but this doesn’t:

function hello(a){
      return true;  
      }  
var abc = undefined;
hello(abc);

Q2 Why is it that this is a valid assignment:

undefined = 10;

But these aren’t:

null = 10;
"hello" = 10;
10 = 10;

Thanks for your help.

  • 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-06-13T20:54:19+00:00Added an answer on June 13, 2026 at 8:54 pm

    In the first case you are not defining the key 'abc' on the global object and thus you are having a reference error trying to access it. It is something like 'Name error' in ruby and python saying that an identifier is undefined.

    These two are equivalent and they both define the 'abc' key on the global object, in your case this is window.

    var abc = undefined;
    var abc;
    

    Defining undefined as an identifier works. It defines the window.undefined key not the undefined type. This means that:

    undefined = 10;
    var a;
    alert(a); // Yeilds undefined
    alert(window.undefined); // Yeilds 10
    

    In order to perform undefined check, check the type of the identifier:

    if (typeof identifier === 'undefined') // Performs undefined check
    

    Because:

    if (identifier === undefined) // Gives us unexpected results 
    // if undefined has been assigned to
    

    In addition undefined is not a primitive. While 0, 'string' are primitives. null is a special singleton object as pointed out in the comments. Those are not identifiers but actual values so you cannot assign to them by specification.

    Update regarding NaN:

    NaN is slightly different because it is a primitive (number). Trying to do the same with NaN yeilds:

    >> typeof NaN
    "number"
    >> NaN = 'a'
    "a"
    >> 0 === NaN
    false
    >> 'a' === NaN
    false
    >> typeof NaN
    "number"
    >> NaN
    NaN
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building this website and I have basically two questions about this page: http://sites.publishyours.com.br/silviamecozzi/pt/obra/deserto_das_palmas.php
I have basically two questions. How do I locate the default Rprofile which is
So basically, I have two fast questions about kohana urls. 1) With default .htaccess
I'm narrowing in on an underlying problem related to two prior questions. Basically, I've
So two part question here. Basically, what is the proper practise for javascript function
I am using WickedPDF, and I have basically two gems that include the binaries:
I have some localization problems in my webpage. There are basically two problems (that
I'm new to programming so forgive my simple questions. Basically, I have two different
I have a static function in a class with two overloads. Both the overloads
I'm curious whether this is even possible. Basically I have two related models. I'm

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.