Hyggelook

关注

模拟new实现

Hyggelook

关注

阅读 114

2023-03-26

function myNew(construct,...args){
  let obj = {};
  obj.__proto__ = construct.prototype
  const r = construct.call(obj,...args)
  return r instanceof Object ? r : obj
}



相关推荐

萨摩斯加士奇

深入理解JavaScript之 new 原理及模拟实现

萨摩斯加士奇 82 0 0

尤克乔乔

new的过程发生了什么,模拟一下new的

尤克乔乔 58 0 0

Python芸芸

【CodeForces - 1020A】New Building for SIS(模拟)

Python芸芸 75 0 0

GG_lyf

ICPC Greater New York Region 2020 (模拟)

GG_lyf 88 0 0

瑾谋

C. New Year Book Reading(CF)模拟

瑾谋 81 0 0

未定义变量

面试官问:能否模拟实现JS的new操作符(高频考点)

未定义变量 60 0 0

Gaaidou

【C++模拟实现】list的模拟实现

Gaaidou 55 0 0

前程有光

通过__new__实现单实例

前程有光 39 0 0

代码小姐

string模拟实现

代码小姐 28 0 0

腊梅5朵

模拟实现atoi

腊梅5朵 66 0 0

精彩评论(0)

0 0 举报