列表

详情


FED10. Object.create

描述

请补全JavaScript代码,要求实现Object.create函数的功能且该新函数命名为"_objectCreate"。

原站题解

HTML/CSS/JavaScript 解法, 执行用时: 1737ms, 内存消耗: 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            const _objectCreate = proto => {\n              return (()=>{}).prototype=proto;\n            }\n        </script>\n    </body>\n</html>","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 1740ms, 内存消耗: 77796KB, 提交时间: 2021-12-09

{"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            const _objectCreate = proto => {\n                // 补全代码\n                if(typeof proto !=='object'||proto===null) return\n                const fn=function(){}\n                fn.prototype=proto\n                return new fn()\n            }\n        </script>\n    </body>\n</html>","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 1740ms, 内存消耗: 77852KB, 提交时间: 2021-12-11

{"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            const _objectCreate = proto => {\n                // 补全代码\n                function Fn(){};\n                Fn.prototype=proto;\n                return new Fn()\n            }\n        </script>\n    </body>\n</html>","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 1741ms, 内存消耗: 77772KB, 提交时间: 2022-01-24

{"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            const _objectCreate = proto => {\n                // 补全代码\n                return (() => {}).prototype = proto;\n            }\n        </script>\n    </body>\n</html>","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 1741ms, 内存消耗: 77776KB, 提交时间: 2021-12-18

{"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            const _objectCreate = proto => {\n                // 补全代码\n                if(typeof proto !== 'object') {\n                    throw new Error('Type Error');\n                }\n                function F(){};\n                F.prototype = proto;\n                return new F;\n            }\n        </script>\n    </body>\n</html>","libs":[]}

上一题