On 12/29/2015 07:38 PM, Joao Rodrigues wrote:
> On 29/12/2015 17:34, Teemu Likonen wrote:
>> Code
>>
>> var Item = function() {
>> this.variable = "variable";
>> this.fn1 = function() { return this.variable; };
>> this.foo = {
>> fn2: function() { return this.variable; }
> ^^^^^^
> Here, 'this.variable' means 'foo.variable', but there isn't such
> identifier in foo, so 'this.variable' will return undefined, according
> to the ECMAScript 5.1, $ 8.7 - The Reference Specification Type. Also
> see $ 10.3.1, 11.1.1 and 11.1.2
Ben Bacarisse got the right reference to the ECMAScript Language
Specification (section 11.2.3 "Function Calls") for this part of the
OP's code.
--
Joao Rodrigues