您所在的位置:小祥子 » 编程 » JavaScript » 正文

javascript权威指南-数据类型笔记

时间:2015-05-26 编辑:图说 来源:本站整理

 原始值与应用值

1.原始值类型数据室不可变的 (改变原始值类型数据, 返回的是一个新的对象)

var str0 = 'test';

var str1 = str.replace('t', 'a');

alert(str1);   // 输出 'aest'

alert(str0);   // 输出 'test'

2.应用值类型是可变的(他的值是可以修改的)

// 对象直接量
var o = {x:1, y:2, z:3};
console.log(o);     // 输出 Object { x=1,  y=2,  z=3}
o.z = 4;
console.log(o);     // 输出 Object { x=1,  y=2,  z=4}

// 数组直接量
var arr = [1, 2, 3];
console.log(arr)     // 输出 [1,2,3]
arr[2] = 4;
console.log(arr)     // 输出[1, 2,4]

几个知识点

1.javascript是ECMAscript的实现,其组成部分有:

2. 原始类型与引用类型(以下是w3school的解释很清晰)

  原始值: 存储在栈(stack)中的简单数据段,也就是说,它们的值直接存储在变量访问的位置。

  引用值: 存储在堆(heap)中的对象,也就是说,存储在变量处的值是一个指针(point),指向存储对象的内存处。

  JSBbFYZN+saZD5hnmfZpORGFhM2EjQ3EzMVNhsVpQMRle/UmlZN3Mm8e/D2x0uVyS7qlsn5Irt+fyDQAAzFxKXwAAAMooWgAADFG0AAAYomgBADBE0QIAYIiiBQDAEEULAIAhihYAAEMULQAAhihaAAAMUbQAABiiaAEAMETRAgBgiKKtzOVyuVwukw8nD34IogBQBV6SKrPYLvPHPwFRAKgCr0eVWWuXD/Q6+2VF2SsEgG+KtiKLLfLJ1TIv2u/P/skDgE+8JFVmsWJLX1RukfvXzwwEgGe8JNVk3qyf/H5p5Lb+o3IA4BwvRjWhUV5xRwugCrwkVSPeKx9YMK8jf3IOAJzjJakai7ewn3xfu3Z//7GBAPCJF6PKzCvkA0tl7QeO749MA4BzvCRVZu2OtuAl5Rf5aeMD0wDgHC9JlYn/YvJja4Z3jwG4xStRZdaK5MPb5WMHB+Afr00AABiiaAEAMETRAgBgiKIFAMAQRQsAgCGKFgAAQxQtAACGKFoAAAxRtAAA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F10Ubf/78synHl38pUR1QdS5XCBmw4KtoL1sOPHnXMROv/PXgqcPvtHaKlAyNLqks1blcIWTAgruiTfzsz5/jjywec29vxY85v4B3LB5t74276mul6lyuEDJgocqijfQrRav6Wqk6lyuEDFjwVbTf6+/0ph9wXqXvvHUcP8XrHxaPuXiKyDPnn0qZMfFTVVOdyxVCBiy4K9pdX7W3hA5cQ/rzj934HrsnpmhhgZABC96LNqVRIreqm7ezi3ecx6450qDfK6V71rmOHaQuqnO5QsiABUdFu6sUJwWZ8uf0R9I/G3lmpM7X2p2ijVCdyxVCBiw4Ktr054e71cUn+ynazefv/ZKUZ6q+VqrO5QohAxaqLNrFz64Vbfpd8puXfaw14z8WHLge1ddK1blcIWTAgk7RLj7+/h1tyhNSjrz4c8Dac965HtXXStW5XCFkwILTol18czh+tLUmO3wNB75q7dex80tdu5nevMk+68eC6qjO5QohAxacFm3Kk9da6sRrqJHqgKpzuULIgAW/RYtjVENWncsVQgYsULRqVENWncsVQgYsULRqVENWncsVQgYsULRqVENWncsVQgYsULRqVENWncsVQgYsULRqVENWncsVQgYsULRqVENWncsVQgYsULRqVENWncsVQgYsULRqVENWncsVQgYsULRqVENWncsVQgYsULRqVENWncsVQgYsULRqVENWncsVQgYsULRqVENWncsVQgYsULRqVENWncsVQgYsULRqVENWncsVQgYsULRqVENWncsVQgYsULRqVENWncsVQgYsULRqVENWncsVQgYsULRqVENWncsVQgYsULRqVENWncsVQgYsULRqVENWncsVQgYsULRqVENWncsVQgYsULRqVENWncsVQgYsULRqVENWncsVQgYsULRqVENWncsVQgYsULRqVENWncsVQgYsULRqVENWncsVQgYsULRqVENWncsVQgYsULRqVENWncsVQgYs5C5aZJDze5pN6VA/RenvMyCIv1cAABiiaAEAMETRAgBgiKIFAMAQRQsAgCGKFgAAQxQtAACGKFoAAAxRtAAAGKJoAQAwRNECAGCIogUAwBBFCwCAIYoWAABDFC0AAIYoWgAADFG0AAAYomgBADD0P+uv4BfY1FXgAAAAAElFTkSuQmCC" border="0" onload="return imgzoom(this,600);"/>

  (*在许多语言中,字符串都被看作引用类型,而非原始类型,因为字符串的长度是可变的。ECMAScript 打破了这一传统。)

3.javascript变量声明及作用域  

  1).js中变量声明有如下几种(分为 使用关键字var , 不使用关键字var)

//------------------------------------------//
// 分别用var声明 var a; var b; a = 'hello'; b = 'world'; // 单var声明 var a, b; // 单var 声明并赋值 var a = 1, b = 2, c; //------------------------------------------// // 不使用var声明 g = 'test'; // 需要注意的是这种不用var声明变量 直接赋值的方式, 在任何地方使用都会被视作全局对象的属性, 可以使用delete删除, 但是不推荐这种用法(EC5严格模式下报错)

  2).js中变量的作用域分为全局作用域()和局部作用域(由函数function构成)俩种

  

  (** js引擎执行时, 每进入一个作用域(环境), 会根据当前上下文, 创建一个针对该环境的上下文对象,在这个阶段,variableObject对象,作用域链,以及this所指向的对象都会被确定推荐阅读)

4. 对象的比较,即使俩个对象包含同样的属性及同样的值, 他们也是不相等的( 各个索引完全相等的两个数组也不相等)

 对象的比较是引用的比较,当且仅当他们引用同一个对象时, 它们才相等

 (这个好比现实中 有姓名相同和年龄相同但是不是同一个人, 但是如果这个人还有个小名(其它引用)那么这个小名和他的大名就都指他一个人了)

var o1 = {name:'zhang', age:23};
console.log(o1);          // 输出Object { x=1,  y=1}

var o2 = {name:'zhang', age:23};
console.log(o1);          // 输出Object { x=1,  y=1}

console.log( o1 === o2 );     // 输出false

var o3 = o1;
console.log(o3);          // 输出Object { x=1,  y=1}

console.log( o3 === o1 );     // 输出true
关键词:数据 类型 笔记