What does this.radioStation refer to in the following code: does 'this.radiostaion' refer to Car or the function chagestation. Your input/ clarification would be appreciated. Any good rule of thumb to clear this up?
var Car = function () {
var gasolineLevel = 10;
function useGas (amt) {
if(gasolineLevel - amt < 0) {
console.log("out of gas :[");
} else {
gasolineLevel -= amt;
}
};
return {
radioStation: "104.5",
changeStation: function (station) {
this.radioStation = station;
},
go: function (speed) { useGas(speed); }
};
};
var Ferrari = Car();
console.log(Ferrari);
console.log(Ferrari.go(2));
console.log(Ferrari.go(10));