Blogger Information
Blog 14
fans 0
comment 0
visits 12053
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
js常用数据类型,变量与常量的声明与赋值
念旧
Original
625 people have browsed it

原始类型:值传递、数值、字符串、布尔、undefind、null

代码

  1. <script>
  2. // 值传递
  3. let a = 100;
  4. let b = a;
  5. console.log(b);
  6. //数值
  7. let int = 123;
  8. console.log(int,typeof int);
  9. //字符串
  10. let str = 'zhao';
  11. console.log(str,typeof str);
  12. //布尔值
  13. let bool = true;
  14. console.log(bool,typeof bool);
  15. //undefined 未定义的变量
  16. let name;
  17. console.log(name,typeof name);
  18. //null
  19. let pass = null;
  20. console.log(pass,typeof pass);
  21. </script>

演示

总结

  1. 常量声明后不能删除,也不能更新
  2. 常量的声明与初始化必须同步完成
  3. 实际工作中尽可能的首选const常量,其次才考虑let
Correcting teacher:天蓬老师天蓬老师

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post