M D
M D

Reputation: 1

Why can't I access the property of an object from a function located in an array of functions

shouldn't it be able to access the object "something"?

var problem = {
    
    something: {thing:23},
    somethingElse: [function(){return this.something.thing}]
    
};
console.log(problem.somethingElse[0]()); //Gives undefined error

I tried to access an object property from a function located within an array of functions, but it looks like it's not within the scope of the function. why is this?

Upvotes: 0

Views: 23

Answers (0)

Related Questions