欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

函数类型和数据类型

程序员文章站 2022-03-01 18:32:27
...

函数类型

数据类型

1.原始类型
number string boolean underfined null
js
‘’’
console.log(123, typeof 123);
console.log(“php”, typeof “php”);
console.log(true, typeof true);
console.log(undefined, typeof undefined);
console.log(null, typeof null);

‘’’
2.引用类型
array object function
2.1 array
js
‘’’
const arr = [“手机”, 2, 5000];
console.log(arr);
console.log(arr[0]);
console.log(arr[1]);
console.log(arr[2]);
console.log(typeof arr);
console.log(Array.isArray(arr));
‘’’
2.2 object
js
‘’’
console.log(123, typeof 123);
console.log(“php”, typeof “php”);
console.log(true, typeof true);
console.log(undefined, typeof undefined);
console.log(null, typeof null);
‘’’
2.3 function
2.3.1 value
js
‘’’
function f2() {
let a = 1;
return function () {
return a++;
};
}
console.log(f2());
const f = f2();
console.log(f());
console.log(f());
console.log(f());
console.log(f());
console.log(f());
console.log(f());
‘’’
2.3.2 object
js
‘’’
function f1(callback) {
console.log(callback());
}
f1(function () {
return “hell 朱老师”;
});
‘’’