Javascript run() function -
var test = function(msg) { alert(msg) }; (new test("hi")).run(); (new test("hello")).run(); when run above javascript code, able alert "hi". alert "hello" not coming up.
- anybody can explain above, new this. know "test" function
what run() method does?, because when removed run in above code, able see both alerts, pls help...
var test = function(msg) { alert(msg) }; (new test("hi")); (new test("hello"));
simple, there no run function, when code runs (new test("hi")).run() runs (new test("hi")) part first, , errors on run second line never executed.
if want call function, call it:
test("hi"); don't run functions (that not constructors) constructors. here what new does.
Comments
Post a Comment