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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:06:21+00:00 2026-06-18T06:06:21+00:00

In Chrome, I’m getting Uncaught ReferenceError: targetNode is not defined from this line of

  • 0

In Chrome, I’m getting “Uncaught ReferenceError: targetNode is not defined” from this line of code console.log(_.isUndefined(targetNode));.

I get the same error when I do console.log(targetNode === void(0)); and console.log(targetNode);.

typeof targetNode === "undefined" returns true as expected, but my understanding is that the void(0) comparison is more efficient.

I can get around this by setting a default for targetNode or I can just use typeof targetNode === "undefined", but I’m trying to understand why a test for whether a variable is undefined would choke if the variable is undefined.

  • 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-18T06:06:22+00:00Added an answer on June 18, 2026 at 6:06 am

    When you ask for targetNode, it looks for a local variable, then in subsequent parent scopes until it reaches the end of the chain. If it still hasn’t found it, there’s an error.

    typeof is special in that it works similar to a try..catch around getting the variable, and returning "undefined" in the catch. Non-native code (such as isUndefined) can’t do that since the variable must be resolved in order to pass it to the function.

    However, if the symbol is defined, it can be validly passed. For example:

    function test(param) {
        console.log(_.isUndefined(param));
    }
    test("argument");
    test(); // undefined argument
    

    Or another example:

    function test() {
        console.log(_.isUndefined(foo)); // true, no error due to hoisting
        var foo = 3;
        console.log(_.isUndefined(foo)); // false, foo is defined now.
    }
    

    You can also specify an explicit source, such as window.targetNode. window is defined, so the script knows where to look, however the targetNode property may not be defined, in which case you get undefined.

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

Sidebar

Related Questions

Chrome Debug Console (Chrome Version 23.0.1271.97) is not showing a Scripts tab for this
Chrome Developer Tools command console provides a handy command : copy() . From example,
Chrome, FireFox and Safari can all log to the console without having the developer
In chrome, ie and safari this is not a problem, but in firefox it
Chrome display this error in console Unsafe JavaScript attempt to access frame with URL
In Chrome, this fiddle prints false . However, the same code typed in the
Chrome's console reports an error. It lists the name of a function -- presumably,
Google Chrome and Firefox deduces the response from the server without problems why doesn't
In chrome and safari, the following code works fine. in firefox , all platforms,
chrome.tabs.executeScript(null, {code:$.each(selectValues, function(key=' + timestamp + ', value='Custom') { $('#expire'). append($(\<option></option>\). attr(\value\,key). text(value)); });});

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.