Correcting teacher:PHPz
Correction status:qualified
Teacher's comments:
// 变量 let
let a = 'kira';
console.log(a);
// 常量
const APP_KIRA= 'PHP中网';
console.log(APP_KIRA);
//1.块作用域
{
//代码段/代码块
let a = 'php中文网';
console.log(a);
}
// 函数作用域
function chufa(a , b){
// 函数内声明的变量 私有变量/局部变量
let res = a / b;
return res;
}
console.log(chufa(10 , 40));
et $user = 111;
console.log($user);
let user_name = 'my name is 蛇形命名法';
console.log(user_name);
let UserName = 'my name is 大驼峰';
console.log(UserName);
const APP_USER = 'KIRA管理员';
console.log(APP_USER);
function sum(a , b){
return a + b;
}
console.log(sum(10 ,20));
let jianfa = function(a , b){
return a - b ;
}
console.log(jianfa(10 ,20));
getChengFa = (a , b) =>{
return a * b ;
};
console.log(getChengFa(10 ,20));
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JS变量/常量/作用域之间的关系</title>
</head>
<body>
1. 变量,常量的声明与初始化
2. 作用域
3. 写出合法标识符的基本规则,并实例演示
4. 实例演示最常用 的三种函数类型
<script>
// 1. 实例演示变量,常量的声明与初始化,使用方法
// 变量 let
let a = 'kira';
console.log(a);
// 常量
const APP_KIRA= 'PHP中网';
console.log(APP_KIRA);
// 作用域
//1.块作用域
{
let a = 'php中文网';
console.log(a);
}
// 函数作用域
function chufa(a , b){
let res = a / b;
return res;
}
console.log(chufa(10 , 40));
// 标识符书写基本规则
let $user =111;
console.log($user);
let user_name = 'my name is 蛇形命名法';
console.log(user_name);
let UserName = 'my name is 大驼峰';
console.log(UserName);
const APP_USER = 'KIRA管理员';
console.log(APP_USER);
// JS函数写法如下
function sum(a , b){
return a + b;
}
console.log(sum(10 ,20));
let jianfa = function(a , b){
return a - b ;
}
console.log(jianfa(10 ,20));
getChengFa = (a , b) =>{
return a * b ;
};
console.log(getChengFa(10 ,20));
</script>
</body>