Here's my function:
function Ship(shipType) {
this.name = shipType;
this.detailedName = function() {
var c=
this.name.charAt(0).toUpperCase() +
this.name.slice(1);
return c;
};
}
Now if I try to optimize = without intermediate variable, this doesn't work. Why?
function Ship(shipType) {
this.name = shipType;
this.detailedName = function() {
return
this.name.charAt(0).toUpperCase() +
this.name.slice(1);
};
}
Here's the fiddle that shows the problem: http://jsfiddle.net/VW5w3/