Mykhaylo Adamovych
Mykhaylo Adamovych

Reputation: 20966

how to get context which method is applied to

deprecated: bad example

Is it feasible to get execution context (object reference) which method is applied to not passing additional reference of 'someObject' as 'someMethod' argument in last line of code?

var someObject = {
    prop1 : 'value1'
};

var someMethod = function() {
    // TODO: how to get prop1 value from here?
};

someMethod.call(someObject);

Thanks.

Upvotes: 0

Views: 82

Answers (2)

c-smile
c-smile

Reputation: 27460

this.prop1 will do the magic for you.

Upvotes: 2

neeebzz
neeebzz

Reputation: 11538

simply someObject.prop1 will get you the value

Upvotes: 2

Related Questions