Function new操作符

Function.prototype.new = function new() {
  var that = Object.create(this.prototype),
        result = this.apply(that, arguments);
  return (
    typeof result === 'object' && result !== null
  ) ? result : that;
}

你可能感兴趣的:(Function new操作符)