js class类 prototype原型链

<script type="text/javascript">
class Person {
constructor(name) {
this.name = name;
};
printName() {
alert(this.name);
}
}
var b = function(name) {
this.name = name;
}
b.prototype.ok = function() {
alert(this.name)
}
new Person('ok').printName();
new b('iii').ok();
</script>

猜你喜欢

转载自www.cnblogs.com/mrt-yyy/p/9836597.html