Blogger Information
Blog 25
fans 0
comment 0
visits 9447
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
前端开发20221101
P粉114035831
Original
345 people have browsed it

变量常量与函数

变量

// * 变量 lat
// 声明
let a
a = 100
// 使用过程
console .log(a=, a)

// * 常量
// 声明
const USER_NAME = “陈小姐”
// 使用过程
console.log(USER_NAME= USER_NAME)

函数

// 命名函数(有提升效果)
// 声明
function sum1(a,b){
return a + b = +(a + b)
}
// 调用:声明后
console.log(sum1(1,2))

// 匿名函数(无提升效果)
const sum2 = function (a, b){
returna + b = + (a + b)
}
// 使用过程
console.log(sum2(5, 6))

// 箭头函数
let sum3 = (a, b) => {
return a + b = + (a + b)
}
console.log(sum3(9, 10))
// 简化
sum3=() => a + b = + (a + b)

var不建议使用的原因

var 不声明能使用
var 可重复声明,易导致混乱
var 变量可泄露,不支持代码k块

Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post