javascript - passing down values to an IIFE function -
this might stupid question have looked everywhere , coming last resort. doubt iife function looks
var me = (function() { /*code*/} )(); me(); i have not seen code has variables passed down far. possible pass down values iife function? have tried using
var person = (function(name,age){ this.name = name; this.age = age; }()); person("bob smith", 30); which gives me undefined error.
so there way pass down these values iife or should avoided?
this iife parameters:
(function (a, b) { alert(a + b); }('hello', ' world')); what seem doing, others said, constructor, there's no need them there.
you constructor way if wanted:
function person(name, age) { this.name = name; this.age = age; } var bob = new person('bob smith', 30); you anonymously invoked constructor, that's pointless since it's one-use type of deal, , wouldn't need constructor that.
Comments
Post a Comment