当前位置:网站首页>es6 0622三
es6 0622三
2022-06-27 04:25:00 【cx&lavender】
let
介绍:声明变量
特点:
1、声明变量,变量不能重复声明
let a = 10;
let a = 20;
console.log(a); // Identifier 'a' has already been declared2、存在块级作用域(只在当前范围有效)
{
let d = 40;
console.log(d); //40
}
// console.log('d', d); //d is not defined3、没有变量提升
console.log(c); //Cannot access 'c' before initialization
let c = 30;const声明常量
介绍:声明常量,一经声明必须赋值
特点:
1、值不可以修改
const A=1;//重新给常量A赋值会报错
A=3;// Uncaught TypeError: Assignment to constant variable.
//错误:赋值给常量2、声明后必须赋值
3、存在块级作用域
{
const d = 60;
console.log(d); //60
}
console.log(d); //d is not defined箭头函数(另一篇有详解)
CSDN
https://mp.csdn.net/mp_blog/creation/editor/125264210
模板字符串
介绍:字符串的增强版,用反引号包裹
语法:
`${变量名}`说明:
1、${变量名} 称为模板占位符,可以在这里插入任意的js表达式,算数运算符甚至函数,也可以在模板字符串中嵌入另一个模板字符串
示例:
let a = 10
let str = `现在${a}点了`
console.log(str);//现在10点了
const username = 'alex';
const person = { age: 18, sex: 'male' };
const getSex = function (sex) {
return sex === 'male' ? '男' : '女';
};
const info = `${username}, ${person.age},${getSex(person.sex)}`;
console.log(info); //alex, 18,男
解构赋值
介绍:按一定模式从数组,对象中提取值,并且赋值给变量
分类:数组解构赋值,对象解构赋值
数组解构赋值:
介绍:按一定模式从数组中提取值,并且赋值给变量
情况:
| 情况 | 示例 |
| 数组长度和变量个数一致时 | |
| 数组长度>变量个数时 | |
| 数组长度<变量个数时 | |
对象解构赋值
介绍:用变量的名字匹配对象的属性 匹配成功将对象属性的值赋值给变量
let person = { name: 'libai', age: 20 };
let {name, age} = person;
console.log(name1) // ' libai '
console.log(age1) // 20
对象解构起别名
let person = { name: 'libai', age: 20 };
let {name: myname , age: myage} = person;
console.log(myname) // ' libai '
console.log(myage) // 20边栏推荐
- Almost because of json Stringify lost his bonus
- 静态时序分析-OCV和time derate
- Building lightweight target detection based on mobilenet-yolov4
- Fastdds server records - Translation-
- 1.5 use of CONDA
- Microservice system design -- unified authentication service design
- List of best reading materials for machine learning in communication
- Quickly master asp Net authentication framework identity - reset password by mail
- Matlab | visualization of mathematical properties related to three interesting circles
- 016 C语言基础:C语言枚举类型
猜你喜欢

Nignx configuring single IP current limiting

Système de collecte des journaux
![[station B up dr_can learning notes] Kalman filter 2](/img/52/777f2ad2db786c38fd9cd3fe55142c.gif)
[station B up dr_can learning notes] Kalman filter 2

卷积神经网络(CNN)网络结构及模型原理介绍

Microservice system design -- microservice monitoring and system resource monitoring design

微服务系统设计——微服务监控与系统资源监控设计

1.5 use of CONDA

Cultural tourism night tour | stimulate tourists' enthusiasm with immersive visual experience
![[BJDCTF2020]The mystery of ip](/img/f8/c3a7334252724635d42c8db3d1bbb0.png)
[BJDCTF2020]The mystery of ip

How to make ef core 6 support dateonly type
随机推荐
真xx相来了?测试/开发程序员为什么不愿意加班,这是个疯狂的状态......
Common sense of Apple's unique map architecture
笔记本电脑没有WiFi选项 解决办法
微服务系统设计——分布式定时服务设计
MATLAB | 三个趣的圆相关的数理性质可视化
There are two problems when Nacos calls microservices: 1 Load balancer does not contain an instance for the service 2. Connection refused
【Unity】UI交互组件之按钮Button&可选基类总结
[station B up dr_can learning notes] Kalman filter 1
Système de collecte des journaux
微服务系统设计——服务注册与发现和配置设计
How to systematically learn LabVIEW?
微服务系统设计——API 网关服务设计
[station B up dr_can learning notes] Kalman filter 3
Facing the "industry, University and research" gap in AI talent training, how can shengteng AI enrich the black land of industrial talents?
733. image rendering
fplan-布局
Games101 job 7 improvement - implementation process of micro surface material
ERP demand and sales management Kingdee
In a sense, the Internet has become an incubator and a parent
文旅灯光秀打破时空限制,展现景区夜游魅力