javascript - pass constructor object into self invoke function -


#1 //pass obj self invoke, works fine var foo = {     a: 1 };  (function(o){     console.log(o.a); })(foo);  #2 //this not working var foo = function(){   this.a = 1;  };  (function(o){   console.log(o); })(foo); 

i'm new in javascript, try pass object self invoke

my problem when try pass constructor obj, not working

anyone know why?

in order #2 work have correct follows;

var foo = (function(){   return this.a = 1;  })();  (function(o){   console.log(o); })(foo); 

Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -