Home > Web Front-end > JS Tutorial > body text

Sharing the differences between const, var and let in js

小云云
Release: 2018-03-13 17:08:42
Original
1180 people have browsed it


This article mainly shares with you the differences between const, var, and let in js. I hope it can help you.

const cannot be modified and must be initialized. The variables defined by

const NAME;
Uncaught SyntaxError: Missing initializer in const declaration

const NAME = 'marain';
NAME = 'marin2'
Uncaught SyntaxError: Missing initializer in const declaration
Copy after login

var can be modified. If not initialized, undefined will be output and no error will be reported.

let Block-level scope, the function is set internally, and has no effect outside the function. It can be used for ( let i = 0; )

Related recommendations:

Detailed explanation of const and define definition constants in PHP

Detailed explanation of the difference between PHP constants define and const

var, let and const in js Differences in usage

The above is the detailed content of Sharing the differences between const, var and let in js. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!