lundi 20 août 2018

some JavaScript Funciton code,Why console.log this? [on hold]

function Foo(){
    bar=function(){console.log(1)};
    return this;
}

Foo.bar=function(){console.log(2)}
Foo.prototype.bar=function(){console.log(3)};
var bar = function(){console.log(4)}
function bar(){
    console.log(5);
}



new bar();
Foo.bar();
Foo().bar();
bar();
new Foo().bar()

try guess what console?and Why this??I can't understand,in Browser environment。




Aucun commentaire:

Enregistrer un commentaire