I am trying iojs, and using the classes new feature.
I just want to create some private method used only in the class itself, but so far cannot work out.
For the following example, I just want the function called "upcase" to be private, how to do it?
class Animal {
constructor(name) {
this._name = name;
}
// failed here
function upcase(word) {
return word.toUpperCase();
};
getName() {
return this.upcase(this._name);
}
get name() {
return this.upcase(this._name);
}
}
let an = new Animal('abc');
console.log(an.getName());
console.log(an.name);
Cheers, Ron