1、基本数据类型只传值

  1. <script>
  2. //基本数据类型在赋值运算中只传值
  3. var a = 20;
  4. var b= a;
  5. console.log(a); //20
  6. console.log(b); //20
  7. </script>

2、引用数据类型 既传值也传址 占两块内存

  1. <script>
  2. var obj = [
  3. {name:"李四"}
  4. ]
  5. var wang = obj;
  6. obj.age = 18;
  7. wang.sex = "男"
  8. console.log(obj);
  9. console.log(wang);
  10. </script>

image.png
image.png