I have this code:
var obj=new function(){
this.var=null;
this.fun=function(funVar){
console.log('funVar: ',funVar);
}
console.log('init',this);
this.fun('fun');
};
obj.var='Something';
obj;
In the console log I have var==null
and also var=='something'
:
I don't understand what is happening.
I was hoping to do something like obj;
to initiate the object. I know how to do obj={init:function(){}}
then use obj.init()
, I was just experimenting and now I'm curios.