Using "prototype" to append a new method to a Class

来源:互联网 发布:中老年保健品数据 编辑:程序博客网 时间:2024/06/04 18:59
If you want to add a method to a class such that all members of the class can use it, we use the following syntax toextend the prototype:
className.prototype.newMethod =function() {statements;};

And we can use "this" in it, just like we literally append this method to the Class constructor body.

0 0
原创粉丝点击