当前位置:网站首页>5、 Constant, variable
5、 Constant, variable
2022-06-13 08:34:00 【001128XY】
1、 Literal ( Constant )
1、 character string
Enclosed in single or double quotation marks
2、 Numbers
Don't distinguish between integers and decimals
3、 Boolean
Two values :true、false
4、Object( Array 、 object )
5、 Custom constant
ES6 New in version , adopt const Custom constants , Constant names are usually capitalized , If it consists of more than one word , It can be separated by underscores
const PI = 3.14
const MY_SITE = 'http://www.baidu.com'
2、 Variable
1、 Variable = Variable name + A variable's value
2、 Declare variables :var
Variables without assignment store undefined
var a;
console.log(a); // undefined
3、 Defining variables
Declaration with assignment
var name; // Declare a variable
var address = "bj"; // Define a variable
4、 Global and local variables
If a variable is declared outside the function , This variable is a global variable , You can access both inside and outside the function
If a variable is declared in the body of a function , This variable is a local variable , Can only be accessed within a function , Cannot be accessed outside a function
Don't use var You can also declare variables , This variable is called Global variables
str1 = "hello"; // Global variables
5、 Define multiple variables at the same time
var c = d = 6; // Equivalent to var c = 6; d = 6; d Global variable
var p = q = j = 888; //q and j No, var, Global variable
// Looking back and forth
// 1、888 Assign a value to j
// 2、j = 888 The whole is a value , The left value , yes 888
// 3、j = 888 The overall value 888 Assign a value to q
// 4、q = 888 The overall value 888 Assign a value to p
边栏推荐
- Dest0g3 520 orientation
- Edge browser uses bdtab new tab plug-in (BD new tab)
- redis.exceptions.ConnectionError: Error 111 connecting to 172.16.8.128:6379. Connection refused.
- Mysql_ Preliminary summary of database data (Continued)
- 1.SolidWorks各模块的学习顺序
- Methods of importing and exporting settings in Altium Designer
- Taobao commodity sales interface / Taobao commodity sales monitoring interface / cumulative commodity sales interface
- Dest0g3 520 orientation
- JS - simple ATM of the for cycle case
- Determine whether a string is rotated from another string
猜你喜欢
JS - set countdown for Date object case
Import the robot model built by SolidWorks into ROS
Bidirectional retransmission step experiment
VS安装VAssistX插件导致WPF-XAML文件输入中文出现乱码问题解决方案
Format_ String_ Server
d3.js&nvd3. JS - how to set the y-axis range - d3 js & nvd3. js — How to set y-axis range
How about a well-known food material distribution information management system?
Using KVM to create three virtual machines that can communicate with local area network
Maternal and infant supplies wholesale industry uses management software to improve efficiency and realize cost reduction and efficiency increase
JS - array de duplication in the array object case
随机推荐
The method of SolidWorks modifying text font in engineering drawing
ERP basic data Kingdee
Process and scheduled task management
微服务项目搭建三:自动生成代码
MySQL query exercise 3
Explanation of JS event loop mechanism and asynchronous tasks
regular expression
Dest0g3 520迎新賽
HCIP_ MGRE comprehensive experiment
Sizeof, strlen find character length
水仙花升级版(自幂数)
MySQL installation and configuration under Windows
JD commodity detail interface, JD detail page interface, baby detail page interface, commodity attribute interface, commodity information query, commodity detail interface, H5 details, JD app details,
How to download and install stm32cubemx
JS gets the first month of the year, the second month to the last month, and the first day to the last day
Microservice system architecture construction I: Environment Construction
Disk management and disk partition operation
Three methods to make the scroll bar of div automatically scroll to the bottom
filebeat采集日志到ELK
MySQL queries difference sets (missing data) by linking tables based on an associated field