function get_denomination(){
return "Fabrice Petard";
}
function auto_flatterie(flatterie){ //
return this.get_denomination() + " est " + flatterie + " !";
}
console.debug(auto_flatterie("le plus intelligent")); // affiche "Fabrice Petard est le plus intelligent !"
Can you explain to what “this” is bound to and why this.get_denomination doesn’t throw any error ?
In the code you posted,
thisis the globalwindowobject. When you create a function in the default global scope (likeget_denomination) it gets attached as a property to thewindowobject.