02 2013 档案

摘要://定义构造函数function Person(name){ this.name = name; //在构造函数中定义成员};//方法定义到构造函数的prototype 上Person.prototype.SayHello = function(){ alert("Hello, I'm " + this.name);};//子类构造函数function Employee(name, salary){ Person.call(this, name); //调用上层构造函数 this.salary = salary; //扩展的成员};//子类构造函数首先需要用上层构造 阅读全文
posted @ 2013-02-03 22:11 feva 阅读(144) 评论(0) 推荐(0) 编辑
摘要:function Person(name) //带参数的构造函数{ this.name = name; //将参数值赋给给this 对象的属性 this.SayHello = function() {console.log("Hello, I'm " + this.name);}; //给this 对象定义一个SayHello 方法。};function Employee(name, salary) //子构造函数{ Person.call(this, name); //将this 传给父构造函数 this.salary = salary; //设置一个this 的 阅读全文
posted @ 2013-02-03 21:31 feva 阅读(204) 评论(0) 推荐(0) 编辑
摘要:function MyFunc() {}; //定义一个空函数var anObj = new MyFunc(); //使用new 操作符,借助MyFun 函数,就创建了一个对象function MyFunc(){};var anObj = {}; //创建一个对象MyFunc.call(anObj); //将anObj 对象作为this 指针调用MyFunc 函数 阅读全文
posted @ 2013-02-03 17:53 feva 阅读(133) 评论(0) 推荐(0) 编辑