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>

posted @ 2018-10-23 14:52  mrt_yy  阅读(1085)  评论(0编辑  收藏  举报