美文网首页
new bind call apply 操作符干了什么

new bind call apply 操作符干了什么

作者: Wang_Yong | 来源:发表于2019-08-03 16:04 被阅读0次

new 操作符

  • 创建了一个新对象
  • 将构造函数的作用域赋值给新对象(因此this就指向了这个新对象)
  • 执行构造函数中的代码
  • 返回新对象
function _new(){
  var args = Array.form(arguments);
  var Func = args[0];
  var  o = {}
  o.__proto__ = args[0].prototype;
  const result = Func.apply(o, args.silice(1, args.length))
  return result instance Object ? result : o
}

bind 操作符干了啥

相关文章

网友评论

      本文标题:new bind call apply 操作符干了什么

      本文链接:https://www.haomeiwen.com/subject/etvjdctx.html