Javascript literals and variables are easy to understand

Javascript literals and variables

1. Literal

Literals are some immutable values

For example: 1 2 3 4 5 6

Literals can be used directly, but we generally do not use literals directly

Two, variables

Variables can be used to save our literal, and the value of the variable can be changed arbitrarily, the variable is more convenient for us to use, so in our development, it is adopted, the variable to save our literal, especially in rare cases will Use literals directly

2.1 Declare variables

Use the var keyword in JS to declare a variable and assign a value to the variable.

Literal quantities can be described by variables

Insert picture description here
The result returned by the browser is:
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_46475440/article/details/108463360