1234567891011121314151617181920212223242526272829 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- </head>
- <body>
- <script>
- /**
- * Symbol
- * 基本数据类型:
- * number null undefined boolean string
- * symbol(新增的):
- * 1.独一无二的值 避免命名冲突 解决命名问题
- * 2.symbol声明的数据类型与其他数据类型不允许做运算
- * 3.symbol 不能使用for...in循环
- *
- */
- let s1 = Symbol();
- console.log(s1);
- console.log(typeof s1);
- let s2 = Symbol("张三");
- let s3 = Symbol("张三");
- console.log(s2===s3); // false
- </script>
- </body>
- </html>
|