new bind call apply 操作符干了什么

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 操作符干了什么)