js的面向对象和设计模式
一.继承:
1. 原型继承(推荐):
参考:
Douglas Crockford: http://javascript.crockford.com/prototypal.html
if (typeof Object.create !== 'function') { Object.create = function (o) { function F() {} F.prototype = o; return new F(); }; } var newObject = Object.create(oldObject);
2. 类式继承(不常用):
参考:
Douglas Crockford:http://javascript.crockford.com/inheritance.html (实现方式的分析:http://www.cnblogs.com/sanshi/archive/2009/07/13/1522647.html)
John Resig:http://ejohn.org/blog/simple-javascript-inheritance/ (实现方式的分析:http://www.cnblogs.com/sanshi/archive/2009/07/14/1523523.html)