FED11. Function.call
描述
请补全JavaScript代码,要求实现Function.call函数的功能且该新函数命名为"_call"。示例1
输入:
Fn._call(object)
输出:
HTML/CSS/JavaScript 解法, 执行用时: 1691ms, 内存消耗: 77808KB, 提交时间: 2022-02-10
{"css":"","js":"","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._call = function(b){\n const context = b || window;\n context.fn = this;\n const res = context.fn(...arguments);\n delete context.fn;\n return res;\n \n \n }\n </script>\n </body>\n</html>","libs":[]}
HTML/CSS/JavaScript 解法, 执行用时: 1739ms, 内存消耗: 77772KB, 提交时间: 2022-01-25
{"css":"","js":"","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._call = function (obj, ...args) {\n obj.fn = this\n return obj['fn'](...args)\n }\n </script>\n </body>\n</html>","libs":[]}
HTML/CSS/JavaScript 解法, 执行用时: 1741ms, 内存消耗: 77772KB, 提交时间: 2021-12-14
{"css":"","js":"","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._call = function(obj, ...rest) {\n obj.fn = this\n let res = obj['fn'](...rest)\n return res\n }\n </script>\n </body>\n</html>","libs":[]}
HTML/CSS/JavaScript 解法, 执行用时: 1744ms, 内存消耗: 77772KB, 提交时间: 2022-01-23
{"css":"","js":"","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._call = function(context,...args){\n context = context || window;\n // let fn = this;\n context.fn = this;\n let ret = context.fn(...args);\n delete context.fn;\n return ret;\n }\n </script>\n </body>\n</html>","libs":[]}
HTML/CSS/JavaScript 解法, 执行用时: 1745ms, 内存消耗: 77772KB, 提交时间: 2021-12-16
{"css":"","js":"","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._call = function(obj){\n return this.call(obj)\n }\n </script>\n </body>\n</html>","libs":[]}