Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the const keyword in js

Shulou Source: shulou.com Published: 2022-06-03 00:22:29 10月14日 Update

This article mainly explains "what is the const keyword in js". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the const keyword in js".

1, when using the const keyword declaration, the variable must be initialized at the same time, the value of the variable can not be modified, otherwise SyntaxError will be thrown.

2. The variables declared by const can only be used to reference the variables they point to, that is, if the const variable refers to an object, modifying the internal properties of the object does not violate the restrictions of const.

Example

Const NUM = 20X const / will report an error / / statement must be initialized const NUM;NUM = 20Tracer / erroneous writing const NUM = 20X const NUM / correct thanks for your reading, this is the content of "what is the const keyword in js". After the study of this article, I believe you have a deeper understanding of what the const keyword is in js, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Keys variables keywords learning content objects keywords writing and at the same time examples that is attributes ideas situations directions articles more knowledge points articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Shulou Technology Redmi Apple Linux