Function new操作符

2022-07-13  本文已影响0人  JamesSawyer
Function.prototype.new = function new() {
  var that = Object.create(this.prototype),
        result = this.apply(that, arguments);
  return (
    typeof result === 'object' && result !== null
  ) ? result : that;
}
上一篇下一篇

猜你喜欢

热点阅读