案例代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>数据类型Symbol</title>
</head>
<body>
<script type="text/javascript" src="js/jquery.js" ></script>
<script>
//1.定义
let strl=Symbol();
let str2=Symbol();
console.log(typeof strl);
//2.描述
let str3=Symbol('name');
let str4=Symbol('name');
console.log(str3);
console.log(str4);
//3.对象属性名(可以解决命名冲突)
const obj={};
obj[Symbol('name')]='张三';
obj[Symbol('name')]='李四';
console.log(obj);
</script>
</body>
</html>