High Performance Javascript
http://www.kuaipan.cn/file/id_4018839553573265.htm
密码:dLgwwl
方法反射调用
Function.call(target_object, arg1,arg2….)
原型继承,非面向对象继承
function Person(name) {
this.name = name;
}
Person.prototype.getName = function() {
return this.name;
}
function Author(name, books) {
this.books = books;
}
Author.prototype=new Person(name);
Author.prototype.constructor=Author;
Author.prototype.getBooks = function() {
return this.books;
}
var au1=new Author("dororo1","Learn much");
var au2=new Author("dororo2","Learn less");
alert(au1.getName()); //dororo1
alert(au2.getName());//dororo1
转载于:https://blog.51cto.com/ericyu/982730