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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:23:34+00:00 2026-06-08T09:23:34+00:00

This is making me angry: If I don’t do this: var a; And then

  • 0

This is making me angry:
If I don’t do this:

var a;

And then do this:

if(a){
    // doing stuff
}

It spits out this error:

ReferenceError: a is not defined

So how can I check if a variable is defined!

Please don’t tell me to use typeof.

EDIT:

a is defined by a library sometimes. I want to check if the library defined it so if not I define it so I can still use it in my code!

  • 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-08T09:23:36+00:00Added an answer on June 8, 2026 at 9:23 am

    If you want to ensure the a is declared, and not causing any reference error problem. You may add a re-declaration statement.

    var a = a;
    

    In this case, if a is defined, nothing changes, otherwise it’s undefined.

    NOTICE: this only works when a is in global scope, check out comments for more details.

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

Sidebar

Related Questions

This is making me very angry, I have worked on this for 2 days,
I' making this class to catch twitter posts but I get the error :
I'm making this prototype script to work: function removing () { *var ids =
This is making me crazy! Musing MySQL DBMS (sorry not for specifying that)... I
This is making me nuts and I'm sure the answer is SO easy. I
I am making this assignment in my program and I am getting the warning
I'm making this game where I'm trying to pair people. So I have this
I was making this very simple lex program (just an introductory program). But on
I'm making this method retrieve records from the Data Base. As you can see
We're making this web app in PHP and when working in the reports we

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.