ES5:
function article(x,y){
this.x = x;
this.y = y;
}
article.prototype.say = function() {
return (this.x + "的年纪=" + this.y)
}
var person = new article('hulk',12);
console.log(person.say())
ES6
class People {
constructor(name, age) {
this.name = name;
this.age = age;
}
say() {
alert("hello")
}
}
class lily extends People {
constructor() {
super( )
}
goodbye() {
alert("goodbye")
}
}
var q = new People;
q.say();// hello
var p = new lily;
p.say(); //hello