题解 | #实现new操作符#

实现new操作符

https://www.nowcoder.com/practice/71c2aff7cb6641099aa17d56157a91b9

{"html":"<!DOCTYPE html>\n<html>\n    <head>\n        <meta charset=utf-8>\n    </head>\n    <body>\n    \t\n        <script type=\"text/javascript\">\n            const _new = function(Contructor) {\n                // 补全代码\n                var obj = {}\n                obj.__proto__ = Contructor.prototype\n                var args = Array.prototype.slice.call(arguments, 1)\n                var result = Contructor.apply(obj, args)\n                if(typeof result === 'object' && result !== null) {\n                    return result\n                }\n                return obj\n            }\n        </script>\n    </body>\n</html>","css":"","js":""}

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-07 11:35
程序员小白条:话太多,没实力和学历,差不多回答回答就行了,身份地位不一样
点赞 评论 收藏
分享
不亏是提前批,神仙打架,鼠鼠不配了
站队站对牛:现在92都报工艺岗了
投递韶音科技等公司7个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务