How to Undefine/Unset A JavaScript Variable???

We can check whether a JavaScript variable is defined or not using the following conditional expression-

typeof some_var == "undefined";

But do you know how to Unset or Undefine a JS variable.

You can use the following syntax for that-

delete window.some_var;// some_var is global

delete this.some_var;// some_var is local to a function.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s