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