Home >Web Front-end >Front-end Q&A >JavaScript has several constants
JavaScript has 5 types of constants, which are: 1. Integer constants, which are actually positive numbers; 2. Real constants, which are actually decimals; 3. String constants, which are actually using single or double quotes. The enclosed content; 4. Boolean constant; 5. Custom constant, defined using the statement "const constant name = constant value;".
The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.
Constants represent some fixed
data
In real life Human gender can actually be regarded as constants. If you are born a boy, you will be a boy throughout your life. If you are born a girl, you will be a girl throughout your life.
positive numbers
. Any integer written in JavaScript is an integer constantdecimal
, which can be used casually in JavaScript Writing a decimal is a real constantSingle quotation marks
or double quotation marks
enclose the content, we call it a string constant or
false, in In JavaScript,
true and
false are used to express
const NUM = 666;
// NUM = 888; //尝试修改NUM这个常量的取值,会发现报错了,常量一旦定义就不能再去改变值了
console.log(NUM);[Recommended learning:
javascript advanced tutorial]
The above is the detailed content of JavaScript has several constants. For more information, please follow other related articles on the PHP Chinese website!