Class ex
by Ben Clayton
JavaScript
class client {
constructor() {
this._forename = "";
this._surname = "";
this._age = 0;
}
// get setter
forename(name) {
if (typeof(name) != "undefined" ) {
this._forename = name.replace(/[0123456789]/g, '');
this._forename = this._forename.charAt(0).toUpperCase() + this._forename.slice(1).toLowerCase();
}
return this._forename;
}
}
var c = new client;
c.forename("bERT99cat");
c.forename("");
console.log( c.forename() );