In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of "can there be spaces in JavaScript variables?" the editor shows you the operation process through actual cases. The method of operation is simple and fast, and it is practical. I hope that this article "can there be spaces in JavaScript variables" can help you solve the problem.
In JavaScript, the variable name cannot have a space, but the variable value can have a space. The variable name can contain numbers, letters, underscores and dollar signs, but can not appear Chinese characters, spaces; and the variable value can have spaces, define the variable value as a string type, for example "var a =" hello world ";".
The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.
The variable name of JavaScript cannot have a space, but there can be a space in the variable value.
Variable name of JavaScript
In JavaScript, variable names cannot be defined casually, and you need to follow the naming rules for identifiers, as shown below:
Variable names can contain numbers, letters, underscores _, and the dollar sign $
Chinese characters cannot appear in variable names
Variable names cannot contain spaces
Variable name cannot be a keyword or reserved word in JavaScript
The variable name cannot start with a number, that is, the first character cannot be a number.
JavaScript keyword breakdeleteifthiswhilecasedointhrowwithcatchelseinstanceoftry
Continuefinallynewtypeof
Debugger (new to ECMAScript 5) forreturnvar
Defaultfunctionswitchvoid
JavaScript reserved word abstractdoublegotonativestaticbooleanenumimplementspackagesuperbyteexportimportprivatesynchronizedcharextendsintprotectedthrowsclassfinalinterfacepublictransientconstfloatlongshortvolatile
When defining a variable, the variable name should be as meaningful as possible so that it can be easily understood by yourself or others. For example, you can use name to define a variable to store the name, and dataArr to define an array type variable.
When the variable name contains multiple English words, it is recommended to use the hump naming method (big hump: the first letter of each word is capitalized, such as FileType, DataArr; hump: the first letter of the first word is capitalized after lowercase, such as fileType, dataArr).
Variable value of JavaScript
After the variable is defined, you can assign a value to the variable using the equal sign =. The one to the left of the equal sign is the name of the variable, and the right side of the equal sign is the value to be assigned to the variable, as shown in the following example:
Var num; / / defines a variable numnum = 1; / / assigns the variable num to 1
JavaScript is a dynamically typed language. When defining variables, you do not need to specify the type of variables in advance. The types of variables are dynamically determined by the JavaScript engine while the program is running. In addition, you can use the same variable to store different types of data, such as:
Var a; / at this time an is Undefineda = "http://c.biancheng.net/"; / / at this time an is String type a = 123; / at this time an is Number type
Data types in JavaScript can be divided into two types:
Basic data types (value types): string (String), number (Number), Boolean (Boolean), empty (Null), undefined (Undefined), Symbol
Reference data types: object (Object), array (Array), function (Function).
String of JavaScript
A string (String) type is a piece of text wrapped in single or double quotes, such as' 123', "abc". It is important to note that single and double quotes are different ways to define a string and are not part of a string.
When defining a string, if the string contains quotation marks, you can use the backslash\ to escape the quotation marks in the string, or select a different quote from the string to define the string, as shown in the following example:
Var str = "Let's have a cup of coffee."; / A double quotation mark contains single quotation marks var str ='He said "Hello" and left.'; / / single quote contains double quotation marks var str ='We\'ll never give up.'; / / use the single quotation marks in the backslash escape string about "can there be spaces in the JavaScript variable". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.