Search code examples
javascriptunset

How to delete or unset a Javascript variable


I have a global variable in Javascript which is already populated by previous function.

I know I can give this variable nonsense values to test but I think there is another way about it. For instance, I've put some_var = undefined and it works for the purpose of testing typeof some_var == "undefined"

Is there a more professional way of approaching this?


Solution

  • delete window.some_var; should do the trick.