1.数据类型
null主动;undefine被动
(1)list:
var l = []
l = [1,2.1,true,[0,1,2]]
console.log(l[0])
console.log(l[1])
console.log(l[2])
console.log(l[3])
(2)dict:
var dict = {}
dict = {
0:true,
hello:3,
}
console.log(dict)
console.log(dict.hello)
console.log(dict["hello"])
console.log(dict.new_key) //undefine
dict.new_key = [1,2,3]
console.log(dict.new_key)
2.函数定义和调用
先创建所有函数对象后执行. 所以当函数名重复时,会保存最后一份.
(1)对象
var func = function (param1, param2) {
console.log("param1: " + param1 + " , param2: " + param2)
}
func(1, 2)
(2)函数名
function function_name(params) {
console.log(params)
}
function_name(123);
3.条件,选择,循环
if (condition) {
} else if (condition) {
} else {
}
switch (key) {
case value:
break;
default:
break;
}
//for
for (let index = 0; index < array.length; index++) {
const element = array[index];
}
//while
while (condition) {
}
//do while
do {
} while (condition);
网友评论