类似于一个构造化的类,使用prototype属性定义方法

<script>
function Person(name) {
this.name = name;
alert(this.name);
}
// 定义Person的原型方法
//Person.method("getName", function() {
Person.prototype.MethodB = function() {
alert( this.name);
// return this.name;
};

// 实例化子类
var nc = new Person("ZhangSan");
nc.MethodB();
</script>

posted on 2013-07-11 09:49  chinaagan  阅读(170)  评论(0编辑  收藏  举报