I have problem with understanding one aspect.
var Car = function(name, loc) {
'use strict';
this.name = name;
this.loc = loc;
this.methods = {
move: function() {
this.loc++;
},
show: function() {
console.log('Position of ' + this.name + ' is: ' + this.loc);
}
};
};
var amy = new Car('amy', 1);
var ben = new Car('ben', 9);
When I use this.loc++ it's referring to methods object, not to Car object. And location of car is not incremented. My question is how to jump to car object context from methods?