摘要: javascript中有原型这么一个概念,任何一个构造函数都有它对应的原型(prototype),我们可以给这个原型赋予一些我们想要的属性,像下面这样:function Gadget(name, color){ this.name = name; this.color = color; this.whatAreYou = function(){ return 'I am a ' + this.color + ' ' + this.name; }}Gadget.prototype.price = 100;Gadget.prototype.rating = 3... 阅读全文
posted @ 2013-12-10 18:31 CodingMonkey 阅读(882) 评论(1) 推荐(0) 编辑