当前位置:网站首页>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
边栏推荐
- three.js 第五十四用如何给shader传递结构体数组
- Complexity analysis learning
- Process tracking of ribbon principle
- Connect with third-party QQ login
- 1. Header file - Comment - namespace - standard input / output stream
- 通过递归实现多级联动
- Raft protocol - process demonstration
- Since 2019, you must have stopped using this marketing strategy
- Some notes on uniapp
- The difference between /g /m /i of JS regular expressions
猜你喜欢

Instance setup flask service (simple version)

机器学习【Numpy】

Simple code implementation of decision tree

Shutter start white screen

for_each用法示例

Deep into C language (1) -- operators and expressions

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

SQL窗口函数

Deep into C language (3) -- input and output stream of C

最新二开版漫画小说听书三合一完整源码/整合免签接口/搭建教程/带采集接口
随机推荐
Functions and comparison of repeaters, hubs, bridges, switches and routers
(newcoder 15079)无关(容斥原理)
[redis series] string data structure
(2022 Hangdian multi school III) 1002 boss rush (pressure dp+ dichotomy)
(nowcoder22529c) diner (inclusion exclusion principle + permutation and combination)
最新二开版漫画小说听书三合一完整源码/整合免签接口/搭建教程/带采集接口
The difference between int and integer. Is int or integer used in practical applications?
"The programming is not standardized, and my colleagues are in tears!"
Shutter start white screen
华为天才少年稚晖君做了一把模块化机械键盘,引起极客圈地震,网友:这才是真正的客制化...
The difference between /g /m /i of JS regular expressions
RTP send and receive h265
Kotlin companion object vs global function
5年多工作经验,工资给15k,要是你,你会接受吗?
Excel拼接数据库语句
Machine learning [numpy]
EMD empirical mode decomposition
向日葵资深产品总监技术分享:“国民远控”如何在AD域环境下应用
three. JS Part 54 how to pass structure array to shader
Simple understanding of CDN, SDN and QoS