题解 | #Function.bind#

Function.bind

https://www.nowcoder.com/practice/ecad0164931847f78c55278cee56e544

{"html":"<!DOCTYPE html>\n<html>\n    <head>\n        <meta charset=utf-8>\n    </head>\n    <body>\n    \t\n        <script type=\"text/javascript\">\n            // 补全代码\n            Function.prototype._bind = function(target, ...arguments1) {\n                if(typeof this !== 'function') {\n                    throw error('this must be a function')\n                }\n                const fn = this;\n                const args = Array.prototype.slice.call(arguments, 1);\n\n                const fBound = function() {\n                    return fn.apply(this instanceof fn ? fn : target, args.concat(Array.prototype.slice.call(arguments)))\n                }\n                function fNop() {}\n\n                fNop.prototype = fn.prototype;\n                fBound.prototype = new fNop();\n\n                return fBound;\n}\n\n            \n        </script>\n    </body>\n</html>","css":"","js":""}

全部评论

相关推荐

10-28 10:48
已编辑
门头沟学院 Java
孩子我想要offer:发笔试后还没笔试把我挂了,然后邮箱一直让我测评没测,后面不知道干嘛又给我捞起来下轮笔试,做完测评笔试又挂了😅
点赞 评论 收藏
分享
12-03 23:38
复旦大学 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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