let group = {
title: "Our Group",
showgroup: function() {
var test = function() {
console.log(this)
}
test();
},
};
group.showgroup()
Asked
Active
Viewed 20 times
0
-
You didn't create an instance here, just an object literal. For oop, use either of there: https://jsfiddle.net/khrismuc/6ocatj0v/ – May 12 '20 at 08:37
-
Because the call that's responsible for determining the `this` context is `test();`, not `group.showgroup()` – Bergi May 12 '20 at 08:38