Node.Js 知识点整理

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);
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容