ES6-Symbol

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script>
// 创建Symbol
let s = Symbol();
// s输出 typeof查看s值类型
console.log(s,typeof s);

let s2 = Symbol('小');
let s3 = Symbol('小');
// false s2,s3 不一样
console.log(s2==s3);

let s4 = Symbol.for('小');
let s5 = Symbol.for('小');
// true s4,s5 一样
console.log(s4==s5);

// 不能于其他数据进行运算
// let result = s+100;
// let result = s>100;
// let result = s+s;

// //值类型
// USONB you are so niubility
// U undefined
// s string symbol
// o Object
// n null Number
// b Boolean
</script>
</body>
</html>

posted @ 2020-08-09 21:33  Smile*^  阅读(70)  评论(0编辑  收藏  举报