Skip to content

Instantly share code, notes, and snippets.

@kzar
Created February 22, 2012 17:10
Show Gist options
  • Select an option

  • Save kzar/1886120 to your computer and use it in GitHub Desktop.

Select an option

Save kzar/1886120 to your computer and use it in GitHub Desktop.
Javascript scope issue
function test() {
return typeof(the_variable) !== 'undefined' && the_variable;
}
(function () {
var the_variable = "doesn't work";
console.log(test());
}());
var the_variable = "does work";
console.log(test());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment