15.symbol.html 587 B

123456789101112131415161718192021222324252627
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Document</title>
  7. </head>
  8. <body>
  9. <script>
  10. /**
  11. * Symbol:独一无二的
  12. * 避免了命名的冲突
  13. * 不能做运算
  14. * 没有办法循环
  15. */
  16. let s1 = Symbol();
  17. let s2 = Symbol();
  18. console.log(s1 + 1);
  19. console.log(s2)
  20. if(s1 === s2) {
  21. console.log("等")
  22. } else {
  23. console.log("不等")
  24. }
  25. </script>
  26. </body>
  27. </html>