Announcement

Collapse
No announcement yet.

Detecting a global variable

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Detecting a global variable

    Hi Guys,
    Is there a way to detect the presence of a global variable before it's absence causes an error ? Obviously the solution is to load the EFS which sets the global first..... but for my client this seems to be easily forgotten. Rather than get the error message :

    TypeError : myGlobal has no properties

    I would like to merely test for it's presence... and put up an alert.

    Thanks
    Chris

  • #2
    Hello Chris,

    Try a null check before attempting to use the variable.

    if (myVar != null) {
    // your code
    }

    If that doesn't solve it, you'll need to post the code so we can see the specific code that is generating the error.
    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment

    Working...
    X