批改状态:合格
老师批语:"runturn"? 态度决定一切, 继续加油,
实例演示JS中变量常量与函数的声明与使用过程
// 变量:// 1. let 是新推出的变量名称,之前有var,以后不推荐使用// 比如: let username = '我爱你中国'2. const 常量// 一般用作于名命,用大蛇名命表达const USER_NAME = '中国人'// 调取过来就是,数据禁止更新,以后推荐使用这个变量console.log('USER_NAME=', USER_NAME)// 声明function sum(a, b){runturn 'a + b =' + (a + b)}function sum7(a, b) {return "a + b =", a + b;}// 可以简写:sum7 = (a, b) => {return a + b}console.log(sum7(1, 2))// 必须遵循先声明后使用原则,为了以后开发方便// 这是先声明,变量不在 funtion 的后面,// 这里的const 也可以用let, 但是为了禁止更新,推荐用const
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号