OReilly JavaScript The Good Parts 关于变量的使用
来源:互联网 发布:吃鸡网络延迟检测 编辑:程序博客网 时间:2024/04/29 16:52
When used well, this can reduce object initialization time and memory consumption.
/*The quotes around a property's name in anobject literal are optional if the name would be a legal JavaScript name and not a reserved word*/var stooge={ name:"hebian", "no.":"001" };//alert(stooge["name"]);//alert(stooge["no."]);
/*Objects can nest*/
var flight = { airline: "spring", number: 123, departure:{ time:"09-22 14:55", city:"shanghai" } };//alert(flight["airline"]);//alert(flight.airline);//alert(flight.departure.time);
/*The || operator can be used to fill in default values:*///alert(flight.arrival || "unknown");/*Attempting to retrieve values from undefined will throw a TypeError exception. This can be guarded against with the && operator:*///alert(flight.arrival && flight.arrival.time);
/*If the property name already exists in the object, theproperty value is replaced:*/flight.number += 1;//alert(flight.number);/*If the object does not already have that property name, the object is augmented:*/flight.arrival = { time:"09-22 19:55", city:"changsha" };alert(flight.arrival.city);
/*Objects are passed around by reference. They are never copied:*/var x = stooge;x.nickname = 'Curly';var nick = stooge.nickname;// nick is 'Curly' because x and stooge// are references to the same objectvar a = {}, b = {}, c = {};// a, b, and c each refer to a// different empty objecta = b = c = {};// a, b, and c all refer to// the same empty object
- OReilly JavaScript The Good Parts 关于变量的使用
- OReilly JavaScript The Good Parts 关于变量Property的访问
- OReilly JavaScript The Good Parts 关于Object.prototype和delete
- JavaScript: The Good Parts
- JavaScript the Good Parts 读书笔记
- 读书笔记 JavaScript:The Good Parts
- JavaScript The Good Parts 代码错误
- 读 《JavaScript: The Good Parts》 有感
- javascript the good parts Chapter 4 Functions
- JavaScript:The Good Parts学习笔记1
- 烂笔头:Javascript The Good Parts
- {Java The Good Parts}
- 《JavaScript:The Good Parts(影印版)》克罗克福特
- JavaScript : the good parts(语言精髓读书笔记)
- The R Formula Method: The Good Parts
- JavaScript Good Parts学习笔记-第二章 语法。
- JavaScript Good Parts学习笔记-第三章 对象
- 使用oreilly的MultipartRequest上传文件
- 有待试用,查看是谁锁住了我的数据库
- Spring源代码分析-Persist--JdbcTemplate
- iframe导航
- js"无缝"滚动原理(解决IE与"火狐"的差异)
- org.apache.jasperException:the absolute uri:http://kava.sun.com/jsp/jstl/c
- OReilly JavaScript The Good Parts 关于变量的使用
- JVM编译时和运行时,内存的分配
- servlet配置详解
- 指令解析
- 数据结构学习(十一)——二叉树的操作
- SQL 聚合函数和空结果集对@@Rowcount的影响
- zip文档中的例子
- android 游戏导引(4. 简单纹理贴图)
- mongodb源码分析(九)mongodb的存储管理