There are two functions here.
1) created with 'new' object.
(
function se(){
var a=10;
var t = function (){
var that=this;
alert(a);
that.book= function (){
alert(that);
}
that.book();
}
return new t();
}()
);
2) With object literal way
(
function se(){
var a=10;
var f={
init:function(){
alert(a);
}
}
f.init();
}()
);
So what is the best practice to use? and why? What is the purpose of using 'this' in the 1st example?
sefunctions are self-invoking here.