当前位置:网站首页>ES6 grammar summary -- Part I (basic)
ES6 grammar summary -- Part I (basic)
2022-07-06 12:07:00 【Aboci Bang】
Variable let
1. There are block level scopes : Variables do not pollute the global scope in the block level scope .
2. There is no claim to promote : Variables can only be used after declaration .
3. Does not affect the scope chain : Variables are normally used in the scope chain .
Constant const
1. The initial value should be assigned when declaring .
2. Constants are generally capitalized .
3. The value of a constant cannot be modified .
4. There are block level scopes .
5. Modifying sub elements of array and object elements is not a constant modification ( Because the address corresponding to the constant has not changed ).
Deconstruct assignment -- Extract values from arrays and objects and assign them to variables
Simple structure
An array of deconstruction :
Object to deconstruct : notes : Variables declared during deconstruction must exist in the object , Deconstruction can be ignored object key The order of ( Put variables a,b Changing positions can also be deconstructed normally )
Complex structure
Complex structure of objects :
names :
Template string A pair of backquotes Support output line wrapping
For variable splicing
be used for dom Splicing
Object simplification -- If the property name and property value in the object are the same , Can simplify writing
Omit attribute values
Omit anonymous functions
Arrow function =>
How to write it
this
this It refers to the scope of the function declaration and will not be changed .
Arrowhead function this
Of a normal function this
Be careful :
1. Arrow functions cannot be instantiated as construction objects
2. Out of commission arguments Variable
The usage scenarios of arrow function
Apply to : And this Unrelated callbacks , Such as : Timer 、 Array methods
Do not apply to : Event callback ( because this Incorrect pointing )、 Object to declare methods
Parameter default
It is customary to write formal parameters with initial values at the end
The basic way of writing
Combined deconstruction assignment And initial value
rest Parameters Get function arguments
notes :...args
Put it at the end of the parameter
Expand operator ( Extension operator ) Convert the array to a comma separated string
Application scenarios
1. Array merge
2. Array Clone -- Deep copy
3. Pseudo array to array (dom object 、arguments etc. )
Technical references :b standing – 【 Silicon Valley 】 I recommend it
https://www.bilibili.com/video/BV1uK411H7on?p=1&vd
边栏推荐
猜你喜欢
Priority inversion and deadlock
IOT system framework learning
Small L's test paper
A possible cause and solution of "stuck" main thread of RT thread
STM32型号与Contex m对应关系
Kaggle竞赛-Two Sigma Connect: Rental Listing Inquiries
open-mmlab labelImg mmdetection
Togglebutton realizes the effect of switching lights
Several declarations about pointers [C language]
C language callback function [C language]
随机推荐
ARM PC=PC+8 最便于理解的阐述
Kconfig Kbuild
AMBA、AHB、APB、AXI的理解
Distribute wxWidgets application
Understanding of AMBA, AHB, APB and Axi
ESP8266使用arduino连接阿里云物联网
5G工作原理详解(解释&图解)
Encodermappreduce notes
高通&MTK&麒麟 手机平台USB3.0方案对比
Feature of sklearn_ extraction. text. CountVectorizer / TfidVectorizer
【ESP32学习-1】Arduino ESP32开发环境搭建
Those commonly used tool classes and methods in hutool
Arm pc=pc+8 is the most understandable explanation
FreeRTOS 任务函数里面的死循环
优先级反转与死锁
XML file explanation: what is XML, XML configuration file, XML data file, XML file parsing tutorial
小天才电话手表 Z3工作原理
Cannot change version of project facet Dynamic Web Module to 2.3.
Detailed explanation of 5g working principle (explanation & illustration)
MySQL START SLAVE Syntax