当前位置:网站首页>The const keyword of ES6 declares variables
The const keyword of ES6 declares variables
2022-07-29 03:45:00 【Haha, APE】
const The keyword is used to declare constants ,const The statement has the following characteristics
The declaration must be assigned an initial value
According to habit questions Identifiers are usually uppercase
Duplicate statements are not allowed
Value cannot be modified
Block level scope ( local variable )
Code block example :
The declaration must be assigned an initial value
// What statement must be given an initial value
const Sun;
// Running results :Uncaught SyntaxError: Missing initializer in const declaration
Duplicate statements are not allowed
const Animal = ' The rabbit '
const Animal = ' The rabbit '
// Running results :Uncaught SyntaxError: Identifier 'Animal' has already been declared
Value cannot be modified ( Modification of array elements and internal modification of objects are allowed ( Arrays and objects store reference addresses )
const Animal = " The rabbit "
Animal = " Little rabbit "
console.log(Animal);
// Report errors : TypeError: Assignment to constant variable
Block level scope
{
const Animal = " The rabbit "
console.log(Animal);
// Print the results : The rabbit
}
console.log(Animal);
// Report errors Uncaught ReferenceError: Animal is not defined
notes : Declare object types using const, Non object type declaration selection let
边栏推荐
- 1. 头文件-注释-命名空间-标准输入输出流
- 2. Variables and scope
- JS regular expression finds the number of times a character (string) appears (one line of code)
- Introduction and comparison of unicast, multicast (target broadcast, multicast), broadcast, flooding, flooding
- How to understand "page storage management scheme"
- SQL窗口函数
- The digitalization of the consumer industry is upgraded to "rigid demand", and weiit's new retail SaaS empowers enterprises!
- EMD 经验模态分解
- MOS管 —— 快速复苏应用笔记(贰)[参数与应用]
- Microcomputer principle and interface technology
猜你喜欢

for_ Example of each usage

Raft protocol - process demonstration

从2019 年开始,你一定停止使用了这个营销策略…

Shutter start white screen

Why BGP server is used in sunflower remote control? Automatic optimal route and high-speed transmission across operators

Sunflower senior product director technology sharing: "how to apply national remote control" in AD domain environment

tron OUT_ OF_ ENERGY

Process tracking of ribbon principle

CUB_ Visualization of key points in 200 bird dataset

(2022 Hangdian multi school III) 1011 link is as bear (thinking + linear basis)
随机推荐
Getting started with caspin
5年多工作经验,工资给15k,要是你,你会接受吗?
(codeforce547) c-mike and foam
Remote desktop connection error
Vs code must know and know 20 shortcut keys!
Set functions in kotlin
SQL窗口函数
深入C语言(1)——操作符与表达式
通过递归实现多级联动
Code ~ hide or disable the status bar and virtual keys
Beijing post network research 2015 problem2
安装抓包证书
Solve the problem of garbled code when opening the project code in idea
Exness: dove resolution helped gold rebound, and the focus turned to U.S. GDP
lodash库常用方法
In depth C language (2) -- definition and use of structure
Sleuth+Zipkin 来进行分布式服务链路的追踪
The difference between int and integer. Is int or integer used in practical applications?
Flask framework operation database_ Add, delete, modify and query statements
Several cases of word wrapping in div