Suppose we have the following Javascript object:
const myObj2 = {
name: "my object",
thisOne: this,
print1: function() {
console.log("(1)", this.thisOne);
console.log("(2)", this);
const innerFuncDecl = function() {
console.log("(3)", this);
};
const innerFuncArrow = () => {
console.log("(4)", this);
};
innerFuncDecl();
innerFuncArrow();
(function(){
console.log("(5)", this);
})();
(() => {
console.log("(6)", this);
})();
},
print2: () => {
console.log("(7)", this);
},
print3: function(){
console.log("(8)", this);
},
};
If I call print1, print2 and print3 from my browser I have:
Questions: