当前位置:网站首页>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边栏推荐
- Argo workflows - getting started with kubernetes' workflow engine
- A^2=e | the solution of the equation | what exactly can this equation tell us
- Cultural tourism light show breaks the time and space constraints and shows the charm of night tour in the scenic spot
- 021 C语言基础:递归,可变参数
- Further exploration of handler (I) (the most complete analysis of the core principle of handler)
- 018 basics of C language: C file reading and writing
- MobileNet系列(4):MobileNetv3网络详解
- Fplan layout
- 卷积神经网络(CNN)网络结构及模型原理介绍
- Nignx configuring single IP current limiting
猜你喜欢

PostgreSQL basic command tutorial: create a new user admin to access PostgreSQL

Installation of low code development platform nocobase

Argo Workflows —— Kubernetes的工作流引擎入门

微服务系统设计——分布式事务服务设计

Microservice system design -- API gateway service design
![[BJDCTF2020]The mystery of ip](/img/f8/c3a7334252724635d42c8db3d1bbb0.png)
[BJDCTF2020]The mystery of ip

Microservice system design -- microservice invocation design
![[station B up dr_can learning notes] Kalman filter 1](/img/18/ee21d31f6a118e4e4ad466b55361cc.gif)
[station B up dr_can learning notes] Kalman filter 1

渗透测试-文件上传/下载/包含

Kotlin Compose 自定义 CompositionLocalProvider CompositionLocal
随机推荐
第1章 绪论
Microservice system design -- microservice monitoring and system resource monitoring design
016 C语言基础:C语言枚举类型
从某种意义来讲,互联网业已成为了一个孵化器,一个母体
[station B up dr_can learning notes] Kalman filter 3
Log collection system
USB DRIVER
Kotlin Compose 隐式传参 CompositionLocalProvider
Facing the "industry, University and research" gap in AI talent training, how can shengteng AI enrich the black land of industrial talents?
与STM32或GD32替换说明
差点因为 JSON.stringify 丢了奖金...
020 basics of C language: C language forced type conversion and error handling
面试-01
015 basics of C language: C structure and common body
Fplan powerplan instance
DAST 黑盒漏洞扫描器 第六篇:运营篇(终)
DAST black box vulnerability scanner part 6: operation (final)
Microservice system design -- message caching service design
百度飞桨“万有引力”2022首站落地苏州,全面启动中小企业赋能计划
Système de collecte des journaux