当前位置:网站首页>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边栏推荐
- 微服务系统设计——分布式定时服务设计
- Description of replacement with STM32 or gd32
- Almost because of json Stringify lost his bonus
- 012 C语言基础:C数组
- Argo Workflows —— Kubernetes的工作流引擎入门
- Microservice system design -- distributed transaction service design
- 文旅夜游|以沉浸式视觉体验激发游客的热情
- DAST 黑盒漏洞扫描器 第六篇:运营篇(终)
- Matlab | visualization of mathematical properties related to three interesting circles
- 007 basics of C language: C operator
猜你喜欢

系统架构设计——互联网金融的架构设计

Office VR porn, coquettish operation! The father of Microsoft hololens resigns!

MATLAB | 三个趣的圆相关的数理性质可视化

渗透测试-目录遍历漏洞

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

Network structure and model principle of convolutional neural network (CNN)

【C语言】关键字的补充

Système de collecte des journaux

LDR6028 手机设备一边充电一边OTG传输数据方案

Kotlin compose implicitly passes the parameter compositionlocalprovider
随机推荐
Microservice system design -- distributed transaction service design
为什么 C# 访问 null 字段会抛异常?
跟着BUU学习Crypto(周更)
Office VR porn, coquettish operation! The father of Microsoft hololens resigns!
MySql最详细的下载教程
MATLAB | 三个趣的圆相关的数理性质可视化
微服务系统设计——服务注册与发现和配置设计
014 C language foundation: C string
iOS开发:对于动态库共享缓存(dyld)的了解
How to make ef core 6 support dateonly type
Microservice system design -- distributed lock service design
ERP demand and sales management Kingdee
微服务系统设计——统一鉴权服务设计
面对AI人才培养的“产学研”鸿沟,昇腾AI如何做厚产业人才黑土地?
Static timing analysis OCV and time derive
微服务系统设计——微服务监控与系统资源监控设计
Further exploration of handler (I) (the most complete analysis of the core principle of handler)
Ledrui ldr6035 usb-c interface device supports rechargeable OTG data transmission scheme.
Six possible challenges when practicing Devops
微服务系统设计——分布式定时服务设计