CoffeeScript的类继承的工具函数extends

__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) {
// 派生类时,如果基类的类属性值是对象,那么子类的类属性只是指向该对象。而不是克隆一份
for (var key in parent) {
if (__hasProp.call(parent, key))
child[key] = parent[key];
}
// 创建一个指定原型的对象
// constructor值
function ctor() { this.constructor = child; }
ctor.prototype = parent.prototype;
child.prototype = new ctor();
// 类属性__super__存储基类的原型对象
child.super = parent.prototype;
return child;
};

原文地址:https://www.cnblogs.com/mackxu/p/extends.html