Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What does the variable in JavaScript mean?

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces what the variable in JavaScript means, the content is very detailed, interested friends can use it for reference, I hope it can be helpful to you.

1. Overview of variables 1.1 Storage of variables in memory

Essence: a variable is a piece of space requested by a program in memory to store data

1.2 use of variables

The use of variables is divided into two steps: 1. Declare variable 2. Assignment

1. Declare variable / / declare variable var age; / / declare a variable named age

Var is a JS keyword that is used to declare variables (meaning of variable variables). After using this keyword to declare variables, the computer will automatically allocate memory space for variables. Age is the defined variable name, and we need to access the space allocated in memory through the variable name.

two。 Assign age = 10; / / assign the age variable a value of 103. Variable initialization var age = 10 position 1.3 variable syntax extension 1. 3. Update variable

When a variable is reassigned, its original value is overwritten, and the value of the variable is subject to the last assigned value.

two。 Declare multiple variables

When you declare multiple variables at the same time, you only need to write a var, and multiple variable names are separated by English commas.

Var age = 10 ~ (th) name = 'lili',sex = 2 ~ (th) 3. Declaration variable special case description result

Var age

Console.log (age)

Only declare that undefinedconsole.log (age) is not assigned; do not declare that no value is assigned and use error reporting directly.

Age = 10

Console.log (age)

Direct use of the 101.5 variable naming convention without declaration

Consists of letters (Amurz), numbers (0-9), underscores (_), and dollar signs ($), such as usrAge,num01,_name

Strictly case-sensitive, var APP; and var app; are two variables

Cannot start with a number

Cannot be keywords or reserved words, such as for, var, while

The variable name must have meaning

Follow the hump naming method. The first letter is lowercase, and the first letter of the following word should be capitalized. MyFirstName

On the meaning of variables in JavaScript to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report