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 is the code specification for JavaScript variable names

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

In this article Xiaobian for you to introduce in detail "what is the code specification for JavaScript variable names", the content is detailed, the steps are clear, and the details are handled properly. I hope that this article "what is the code specification for JavaScript variable names" can help you solve your doubts.

JavaScript code specification

Code specifications usually include the following aspects:

Naming rules for variables and functions

Rules for the use of spaces, indentation, and comments.

Other commonly used specifications...

Canonical code can be easier to read and maintain.

Code specifications are generally specified before development, and you can negotiate settings with your team members.

Variable name

It is recommended to use the hump method to name the variable name (camelCase):

FirstName = "John"

LastName = "Doe"

Price = 19.90

Tax = 0.20

FullPrice = price + (price * tax)

Spaces and operators

Usually a space needs to be added before and after the operator (= +-* /):

Example:

Var x = y + z

Var values = ["Volvo", "Saab", "Fiat"]

Code indentation

You typically use four space symbols to indent a block of code:

Function:

Function toCelsius (fahrenheit) {

Return (5 / 9) * (fahrenheit-32)

}

After reading this, the article "what is the code specification for JavaScript variable names" has been introduced. If you want to master the knowledge of this article, you still need to practice and use it to understand it. If you want to know more about related articles, you are welcome to follow the industry information channel.

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