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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:39:54+00:00 2026-05-27T21:39:54+00:00

Both scenario, the typeof the variable will be undefined. But undeclared variable will raise

  • 0

Both scenario, the typeof the variable will be “undefined”.
But undeclared variable will raise a exception.

Is there a easy way to handle this?

  • 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-27T21:39:55+00:00Added an answer on May 27, 2026 at 9:39 pm

    You may find the question (and my answer) in How to check if a variable or object is undefined? relevant. In general, I view any access to an “undeclared variable” a programming error.

    However, this particular case can *only** be detected with the use of detecting for a ReferenceError exception. But, yuck, yuck, yuck! Remember variable declarations are a static lexical construct, ignoring the quirks with property-variables of the global object.

    ReferenceError, and now “strict”, exist for a reason and I suspect this is an X-Y problem. I do not even recommend the use of typeof for this purpose: fix the code 🙂

    Happy coding.


    *It has been pointed out that "variable" in window will also [and only] work for global “variables” (they are really just properties that don’t need be qualified in all contexts).

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

Sidebar

Related Questions

The scenario is this We have two applications A and B, both which are
Both ideas sound very similar to me, but there might be subtle differences or
Similar threads that addresses this are possibly there on SO, but I do not
I have scenario, I have two update panels on the page (both have update
I'm hoping someone can advise me on how to solve my networking scenario. Both
I have this scenario and I'm not sure exactly how it should be modeled
I will start by explaining my scenario in code: public class A { }
I am having difficulties with listing this type of data. Scenario is as follows:
This comes from the Rails world, but is a pretty generic question about Single
Here's the scenario: I want to be able to support both SQL Server CE

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.