当前位置:网站首页>ES6 0622 III
ES6 0622 III
2022-06-27 04:27:00 【cx&lavender】
let
Introduce : Declare variables
characteristic :
1、 Declare variables , Variables cannot be declared repeatedly
let a = 10;
let a = 20;
console.log(a); // Identifier 'a' has already been declared2、 There are block level scopes ( Only valid in the current range )
{
let d = 40;
console.log(d); //40
}
// console.log('d', d); //d is not defined3、 No variable Promotion
console.log(c); //Cannot access 'c' before initialization
let c = 30;const declare constant
Introduce : declare constant , Once declared, the value must be assigned
characteristic :
1、 The value cannot be modified
const A=1;// Reset constant A The assignment will report an error
A=3;// Uncaught TypeError: Assignment to constant variable.
// error : Assign to constant 2、 Must be assigned after declaration
3、 There are block level scopes
{
const d = 60;
console.log(d); //60
}
console.log(d); //d is not definedArrow function ( Another article has a detailed explanation )
CSDN
https://mp.csdn.net/mp_blog/creation/editor/125264210
Template string
Introduce : Enhanced version of string , Wrap in back quotation marks
grammar :
`${ Variable name }`explain :
1、${ Variable name } Called a template placeholder , You can insert any... Here js expression , Arithmetic operators and even functions , You can also embed another template string in the template string
Example :
let a = 10
let str = ` Now? ${a} O 'clock `
console.log(str);// Now? 10 O 'clock
const username = 'alex';
const person = { age: 18, sex: 'male' };
const getSex = function (sex) {
return sex === 'male' ? ' male ' : ' Woman ';
};
const info = `${username}, ${person.age},${getSex(person.sex)}`;
console.log(info); //alex, 18, male
Deconstruct assignment
Introduce : From an array in a certain pattern , Object , And assign values to variables
classification : Array deconstruction assignment , Object deconstruction assignment
Array deconstruction assignment :
Introduce : Extract values from an array in a certain pattern , And assign values to variables
situation :
| situation | Example |
| When the array length is the same as the number of variables | |
| The length of the array > Number of variables | |
| The length of the array < Number of variables | |
Object deconstruction assignment
Introduce : Match the attributes of the object with the name of the variable Match successfully assigned the value of the object property to the variable
let person = { name: 'libai', age: 20 };
let {name, age} = person;
console.log(name1) // ' libai '
console.log(age1) // 20
Object deconstructs the alias
let person = { name: 'libai', age: 20 };
let {name: myname , age: myage} = person;
console.log(myname) // ' libai '
console.log(myage) // 20边栏推荐
- 日志收集系統
- Microservice system design -- service registration, discovery and configuration design
- Matlab | drawing of three ordinate diagram based on block diagram layout
- Advanced Mathematics (Seventh Edition) Tongji University exercises 1-10 personal solutions
- 【B站UP DR_CAN学习笔记】Kalman滤波3
- 006 C language foundation: C storage class
- 017 basics of C language: bit field and typedef
- 1.5 conda的使用
- ERP demand and sales management Kingdee
- 办公室VR黄片,骚操作!微软HoloLens之父辞职!
猜你喜欢

Building lightweight target detection based on mobilenet-yolov4

微服务系统设计——服务熔断和降级设计

低代码开发平台NocoBase的安装

Microservice system design -- API gateway service design

Baidu PaddlePaddle's "universal gravitation" first stop in 2022 landed in Suzhou, comprehensively launching the SME empowerment plan
![[BJDCTF2020]The mystery of ip](/img/f8/c3a7334252724635d42c8db3d1bbb0.png)
[BJDCTF2020]The mystery of ip
![[array]bm94 rainwater connection problem - difficult](/img/2b/1934803060d65ea9139ec489a2c5f5.png)
[array]bm94 rainwater connection problem - difficult

Ldr6028 OTG data transmission scheme for mobile devices while charging

WPF 开源控件库Extended WPF Toolkit介绍(经典)

Microservice system design -- service registration, discovery and configuration design
随机推荐
014 C language foundation: C string
Almost because of json Stringify lost his bonus
Argo workflows - getting started with kubernetes' workflow engine
Advanced Mathematics (Seventh Edition) Tongji University exercises 1-10 personal solutions
Mysql database foundation: DQL data query language
微服务系统设计——分布式缓存服务设计
Cultural tourism light show breaks the time and space constraints and shows the charm of night tour in the scenic spot
笔记本电脑没有WiFi选项 解决办法
QChart笔记2: 添加鼠标悬停显示
清华大学开源软件镜像站网址
Fplan powerplan instance
Baidu PaddlePaddle's "universal gravitation" first stop in 2022 landed in Suzhou, comprehensively launching the SME empowerment plan
深潜Kotlin协程(十五):测试 Kotlin 协程
006 C language foundation: C storage class
016 C语言基础:C语言枚举类型
办公室VR黄片,骚操作!微软HoloLens之父辞职!
微服务系统设计——统一鉴权服务设计
百度飞桨“万有引力”2022首站落地苏州,全面启动中小企业赋能计划
iOS开发:对于动态库共享缓存(dyld)的了解
006 C语言基础:C存储类