javaScript closures. Undefined value as input stops script. Sometimes -


playing javascript closures end question cannot reach explain.

(function() {     console.log("inside closure"); //does not work }(foo)); 

it not work because foo undefined. referenceerror

but if prior set var foo = undefined; works (tested on chrome , ff).

it not same undefined set undefined?

example in jsfiddle

in javascript, 'undefined' 1 of primitive data types. represents type of object.

var = undefined; var b;  console.log((typeof(a))); console.log((typeof(b))); 

the output undefined both cases.

if don't declare variable @ , try access it, error thrown following. tried access c not declared @ all. uncaught referenceerror: c not defined(…)


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -