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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:05:31+00:00 2026-06-08T11:05:31+00:00

If the variable foo is undefined, normally I can do things like: !foo; foo

  • 0

If the variable foo is undefined, normally I can do things like:

!foo;
foo === undefined;
foo !== 'some value';

However, the code base that I am working on now has something in it that seems to instruct the browser’s interpreter to throw an exception for any operation on an undefined variable other than this:

typeof foo !="undefined";

I’m working in the same browsers that I normally work in (Chrome and Firefox). But I’m coming on to this project in the middle this time instead of starting from scratch. It is a dJango project using Backbone.js, underscore, handlebars, jQuery, yepnope.

Could this behavior be due to the instruction "use strict" appearing somewhere in the global namespace? I did a search in the project for the text string “use strict” and found it in some code that seems to come from twitter:

    Files: bootstrap.js
           script.js
    From:  http://twitter.github.com/bootstrap/javascript.html#transitions

I also found it in the json2 file. However I’m pretty sure this file didn’t cause me problems last time I worked with it:

    File: json2.js
    From: http://www.JSON.org/json2.js

For all I know, this isn’t even caused by the inclusion of “use strict” somewhere…

Any ideas?

Thanks so much!

  • 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-08T11:05:33+00:00Added an answer on June 8, 2026 at 11:05 am

    There’s an important difference between undefined and undeclared.

    function test() {
        var foo;
        if (foo) { /* not executed */ }
    }
    

    This is fine because foo is declared, but its value is undefined.

    function test() {
        if (foo) { /* exception! */ }
    }
    

    This will throw an exception (ReferenceError) because foo is not declared. (Unless there is a window.foo.)

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

Sidebar

Related Questions

I have something like the following code:: <xsl:variable name=sample> <xsl:copy-of select=//foo> <xsl:copy-of select=//bar> </xsl>
I have some code that is failing due to an error: The name 'foo'
I have a variable foo that contains a time, lets say 4pm today, but
Given this variable in tcsh: set i = ~/foo/bar.c how can I get just
I have a function that accepts a variable number of parameters: foo (Class... types);
Suppose I have a class Foo , with a private variable bar_ containing some
Recently I saw the following code that creates a class in javascript: var Model.Foo
Why does the following code result in the error 'undefined local variable or method
I have a function like so function foo(x){ if (typeof x === 'undefined'){ var
Does python have some undefined variable / debug mode which will output a notice/warning?

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.