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 someObj开发者_开发百科ect = {
prop1 : 'value1'
};
var someMethod = function() {
// TODO: how to get prop1 value from here?
};
someMethod.call(someObject);
Thanks.
this.prop1
will do the magic for you.
simply someObject.prop1
will get you the value
精彩评论