Taking the following example from:
<http://www.phpied.com/3-ways-to-define-a-javascript-class/>

```
var apple = {
    type: "macintosh",
    color: "red",
    getInfo: function () {
        return this.color + ' ' + this.type + ' apple';
    }
};

```

Now I am moving the getInfo() method at the top of my object declaration.

```
var apple = {
    getInfo: function () {
        return this.color + ' ' + this.type + ' apple';
    },
    type: "macintosh",
    color: "red",
};

apple.getInfo();
red macintosh apple

```

I was expecting the javascript parser/compiler to fail, since this.color and this.type are not yet defined. How does this work internally ?

( this question was originally a ExtJS framework question here: [ExtJS: settings properties via a function on the Prototype: is it a safe pattern?](https://stackoverflow.com/questions/32205685/extjs-settings-properties-via-a-function-on-the-prototype-is-it-a-safe-pattern/32257445#32257445), but I realized it is a more general javascript question, hence this new one)