<script> function myNew(constructor, ...args){ let obj = {}; constructor.call(obj, ...args); obj.__proto__ = constructor.prototype; return obj; } function myClass(){ this.name = 'Do'; } let obj = myNew(myClass); console.log(obj.name); </script>
Javascript仿写new运算符,new的运行原理
猜你喜欢
转载自www.cnblogs.com/xieyicn/p/11685366.html
今日推荐
周排行