那天用到prototype.js于是打开看看,才看几行就满头雾水,原因是对js的面向对象不是很熟悉,于是百度+google了一把,最后终于算小有收获,写此纪念一下^_^。
prototype.js代码片段
|
var Class = { create: function() { return function() { this.initialize.apply(this , arguments); } } } // Class使用方法如下 var A = Class.create(); A. prototype={ initialize:function(v){ this .value=v; } showValue:function(){ alert(this.value); } } var a = new A(‘helloWord!’); a. showValue();//弹出对话框helloWord! |
l initialize是什么?
l <
验证码:
注册会员 会员登陆