批改状态:合格
老师批语:
(1)命名函数
// 1.命名函数function firstName(name){return name;}console.log(firstName('小明'));

(2) 匿名函数
// 2.匿名函数let getName = function(name){return 'Hello '+ name;}console.log(getName('张三'));

(3)立即调用函数
// 立即调用函数console.log((function(name){return 'Hello '+name;})('李四'));

(4) 箭头函数
// 箭头函数test = (a,b) => {console.log(a + ' + ' + b +' = '+ (a+b))}test(3,4);

(1)原始类型
// 原始类型 number, string, boolean,undefined, nullconsole.log(typeof 100);console.log(typeof 'hello');console.log(typeof true);console.log(typeof undefined);console.log(typeof null);

(2) 用类型
// 引用类型 array, object, functionconst arr = [1, 'admin', [1, 2, 3], true];console.log(arr);let obj = { id:1, name:'王五',num:[1,2,3],isOk:true,'test name':'skdjf@qq.com'};console.log(obj.username+','+obj['test name']);function f1(callback) {console.log(callback());}f1(function() {return 'Hello 刘六';});

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号