In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail what const means in javascript. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
In JavaScript, const means "immutable" and is a keyword used to declare one or more constants. The declaration must be initialized, and the value can no longer be modified after initialization. If you change the value of a constant, it will cause a type error. The syntax is "const constant name = constant value;".
The operating environment of this tutorial: windows10 system, javascript1.8.5 version, Dell G3 computer.
What is the meaning of const in javascript
ES2015 (ES6) adds two important JavaScript keywords: let and const.
Variables declared by let are valid only within the block of code where the let command is located.
Const declares a read-only constant, and once declared, the value of the constant cannot be changed.
Used to declare one or more constants, which must be initialized, and the value cannot be modified after initialization
Const defines constants similar to variables defined using let:
Both are block-level scope
Cannot have the same name as any other variable or function in its scope
There are two other differences between the two:
Constants declared by const must be initialized, while variables declared by let do not
The value of the const definition constant cannot be modified by re-assignment, nor can it be declared again. The value of the variable defined by let can be modified.
Examples are as follows:
123 JavaScript const
Const is used to declare one or more constants, which must be initialized at the time of declaration, and the value cannot be modified after initialization.
Try {const PI = 3.141592653589793; PI = 3.14;} catch (err) {document.getElementById ("demo") [xss_clean] = err;}
Output result:
This is the end of the article on "what does const in javascript mean?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.