Blogger Information
Blog 19
fans 0
comment 6
visits 19036
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
JS常用数据类型,变量,常的声明与赋值
葵花宝典
Original
723 people have browsed it

JS 常用数据类型,变量,常的声明与赋值

JS 演示比较抽象,只能以代码加注释来说明了

  1. <script>
  2. // 申明一个变量, 可以不用赋值
  3. let rows;
  4. //变量赋值
  5. rows = 10 ;
  6. //申明一个常量, 常量在申明时必须赋值,赋值后不能修改,如果修改对象其中一个属性是可以的
  7. //或修改数组其中一个下标的值是可以的
  8. const arr = [1,2,3];
  9. // 重新赋值,不可以 arr=[1,2,3,4];
  10. // 修改下标值可以 arr[0]=10;
  11. //JS数据类型
  12. //值类型,也叫原始类型,是值传递
  13. let cols = rows;
  14. //引用类型,它是将一个变量的内存地址引用给其它变量
  15. let obj = {code:"007",userName:"零零柒"};
  16. console.table(obj);
  17. let obj1 = obj;
  18. //改变对象其中一个属性
  19. obj.code="001";
  20. console.table(obj);
  21. //obj1的值也跟着变化
  22. console.table(obj1);
  23. </script>

执行结果:

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