@lijianying10
2017-02-27T13:08:12.000000Z
字数 625
阅读 841
var x=2;
var y=3;
var z=x+y;
//不推荐:
x=2;
var x // x 为 undefined
var x = 6; // x 为数字
var x = "Bill"; // x 为字符串
//注意:
typeof(x)
function myFunction() {
}
// 回调函数
function myFunction(func2) {
}
if (条件){
只有当条件为 true 时执行的代码
}
switch(n){
case 1:
执行代码块 1
break;
case 2:
执行代码块 2
break;
default:
n 与 case 1 和 case 2 不同时执行的代码
}
for (var i=0;i<cars.length;i++)
{
document.write(cars[i] + "<br>");
}
while (条件)
{
需要执行的代码
}
拓展可以学习函数式编程
person=new Object();
person.firstname="Bill";
person.lastname="Gates";
person.age=56;
person.eyecolor="blue";