摘要:
JS中的对象是一种复合数据类型,将多个数据值集中在一个单元中,允许使用名字来存取这些值。也可以理解为:对象是一个无序的属性集合,每个属性都有自己的名字和值。一、创建//直接加入一个对象直接量,是用逗号分隔开的一对对的属性名和值的列表
var empty = {};
var point = {x:0,y:0};
var circle = { x:point.x,y:point.y+1,radius:2};
var homer={ "name":"Home Simpson", "age":34, "married":t 阅读全文
摘要:
一、if 等常规语句略过啦,大家都会的。二、switchswitch (n){ case 1: //Execute code block #1. break; case 2: //Execute code block #2. break; case 3: //Execute code block #3. break; case 4: //Execute code block #4. break; default: //Execute... 阅读全文
摘要:
一、带操作的赋值运算符1.+= 执行加法和赋值运算total+=sales_tax;
//等同于
total=total+sales_tax;二、条件运算符1.三元运算符greeting = "hello" + (username != null ? username : "there");
//等价于
greeting = "hello";
if(username != null) greeting += username;
else greeting += "there";三、typeof 运算符1.放在一个运 阅读全文