- 类型
基本类型:访问基本类型时,应该直接操作类型值
string number boolean null undefined
var a = 0 ;
var b = a ;
b = 8 ;
console.log(a,b) ; //0,8注:
1、JavaScript中调用console写日志。
2、打开IE开发者工具后才能使用console,默认访问IE的console对象会出错。
复合类型:访问复合类型时,应该操作其引用
object array function
var a = [1,2] ;
var b = a ;
b[0] = 9
console.log(a[0],b[0]);//9,91:1 In the beginning God created the heaven and the earth.
本文探讨了JavaScript中基本类型与复合类型的访问方式差异。基本类型如字符串、数字等可以直接操作值;复合类型如对象、数组则通过引用进行操作。文章通过示例展示了不同类型的变量赋值与修改行为。
2108

被折叠的 条评论
为什么被折叠?



