下面的工作twin(source)函数生成一个新对象,该对象具有与相同的属性source和相同的父对象(原型链)。(例如twin(isFinite)是[object Object]and instanceof Function)是否有任何本机功能提供相同的效果?
/**
 * @param {Object|Function} source
 * @param {(Object|Function|null)=} parent defaults to source's parents
 * @return {Object}
 */
function twin(source, parent) {
    var twin, owned, i = arguments.length;
    source = i ? source : this; // use self if called w/o args
    parent = 2 == i ? parent : Object.getPrototypeOf(source);
    twin = Object.create(parent);
    owned = Object.getOwnPropertyNames(source);
    for (i = owned.length; i--;) {
        twin[owned[i]] = source[owned[i]];
    }
    return twin;
}
更新:血液中提供了一种.twin方法。