Can anyone explain to me why X is undefined? 123 should not be?
doSomething = (function (x) {warning (x)}) (); DoSomething (123);
doSomething function is not undefined < / Code>.
doSomething = (function (x) {warning (x)}) ();
This announces an anonymous function, immediately executes it (this is what () does) Then sets for return value - undefined . Your anonymous function takes a parameter ( x ), but nothing is given to it, so x is undefined .
You might want to:
doSomething = function (x) {warning (x)}; DoSomething (123);
Comments
Post a Comment