ZhengXingchi / ZhengXingchi.github.io

Apache License 2.0
0 stars 0 forks source link

new的实现 #58

Open ZhengXingchi opened 4 years ago

ZhengXingchi commented 4 years ago
   function newObj() {
      let constructor = [].shift.call(arguments)
      let obj = new Object()
      obj._prop_ = constructor.prototype
      var returnObj = constructor.apply(obj, arguments)
      return typeof returnObj === 'Object' ? returnObj : obj
    }