es6:数据类型 symbol

六眼飞鱼酱① 提交于 2019-12-18 09:56:44

es6:数据类型 symbol

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>数据类型 symbol</title>
</head>
<body>
    <script>
        const peter = Symbol('peter');//创建唯一标志符
        const calssRoom = {
            [Symbol('a')]:{age:12},
            [Symbol('b')]:{age:142},
            [Symbol('b')]:{age:13}
        }

        const  syms = Object.getOwnPropertySymbols(calssRoom).map(sym => calssRoom[sym]);
        console.log(syms)
    </script>
</body>
</html>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!