node.js第一天

var a = ['hello','world'];
 console.log(typeof(a));//object
 var b =a;
 b[0] = 'bye';
 console.log(a[0]);//'bye'
 console.log(b[0]);//'bye'
 
 console.log(typeof(b));//object
 a instanceof String;
 b instanceof String
 
 
 // JavaScript类型简单分为两组 简单数据类型和复杂数据类型
// 简单数据类型:number Boolean String null undefined
// 复杂数据类型:array function abject
// 访问基本类型 访问的是值
// 访问复杂类型 访问的是对值的引用 b和a包含了对值的相同引用 
// 因此通过b修改数组第一个元素时 a相应的值也改变
 
 
 
 
var c = 'woot';
var d = new String('woot')
console.log(a + b);
console.log(typeof(c));//string
console.log(typeof(d));//object
console.log(c instanceof String);//flase
console.log(d instanceof String);//true

猜你喜欢

转载自www.cnblogs.com/treasurea/p/11228325.html