批改状态:合格
老师批语:
// 1.四种常见函数类型//1.命名函数function QQQ(a, b) {return `${a}+${b}=` + (a + b); //模版字面量,支持表达式}console.log(QQQ(1, 2));//2.匿名函数const ssj = function (a, b) {return `${a}+${b}=` + (a + b);};console.log(ssj(2, 2));//3.立即执行函数IIFElet resull = (function (a, b) {return `${a}+${b}=` + (a + b);})(3, 5);console.log(resull);//4.箭头函数(箭头函数没有自己的this)//单参数可省()let a123 = a => a + a; //只有一个返回值时可省{}console.log(a123(22));//无参或多参let a1234 = () => 5 * 5;console.log(a1234());// 2.原始数据类型:`string`, `number`, `boolean`, `null`, `undefined`;// 引用数据类型:`array`, `object`, `function`;const arr = [10, "admin", true]; //数组console.log(arr[2]);let user = { id: 100, uname: "admin" }; //对象console.log(user.uname); //如果属性都是合法标识符,可用‘.’来访问成员,不是的只能用[]//函数是对象,所以可以添加属性

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