列表

详情


JS24. Symbol

描述

请补全JavaScript代码,要求以键/值对的对象形式返回参数数组。要求如下:
1. 键名的数据类型为Symbol
2. 键值为当前数组项
3. Symbol的描述为当前数组项
4. 返回普通对象

原站题解

HTML/CSS/JavaScript 解法, 执行用时: 1680ms, 内存消耗: 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            const _symbolKey = array => {\n                // 补全代码\n                let JSON1 = {}\n                for(item of array){\n                    let key = Symbol (item);\n                    JSON1[key] = item;\n                }\n                return JSON1;\n            }\n        </script>\n    </body>\n</html>","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 1689ms, 内存消耗: 77812KB, 提交时间: 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            const _symbolKey = array => {\n                // 补全代码\n                let obj = {};\n           for(item of array) {\n                let key = Symbol(item)\n                obj[key] = item\n            }\n                 return obj;\n            }\n        </script>\n    </body>\n</html>","libs":[]}

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

{"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 _symbolKey = array => {\n                // 补全代码\n                let obj={};\n                array.forEach(item=>{\n                    obj[Symbol(item)]=item;\n                })\n                return obj;\n            }\n        </script>\n    </body>\n</html>","libs":[]}

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

{"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 _symbolKey = array => {\n    let object = {}\n    for(item of array) {\n        let key = Symbol(item)\n        object[key] = item\n    }\n    return object\n}\n\n        </script>\n    </body>\n</html>","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 1735ms, 内存消耗: 77776KB, 提交时间: 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            const _symbolKey = array => {\n                // 补全代码\n                let object = {}\n                for(item of array){\n                    let key = Symbol(item)\n                    object[key] = item\n                }\n                return object\n            }\n        </script>\n    </body>\n</html>","libs":[]}

上一题