2.2 Variables
Variables are declared with VAR, the variable's naming rule: the first character must be a letter, an underscore, or a dollar sign; the remaining characters can be underscores, dollar signs, or any letter or numeric character.
Variable Naming conventions:
Camel notation: The first letter is lowercase, and the next word begins with an uppercase letter. For example: Var mytestvalue=0,mysecondtestvalue= "HI";
Pascal notation: Capitalize the first letter, and the next words begin with an uppercase letter. For example: Var mytestvalue=0,mysecondtestvalue= "HI";
Hungarian type notation: appends a lowercase letter (or lowercase alphabetical sequence) to a variable named after the Pascal notation, indicating the type of the variable. For example, I represents an integer and S represents a string, as shown here:
var imytestvalue=0,smysecondtestvalue= "HI";
The prefix used to define ECMAScript variables using Hungarian type notation is as follows:
Type: Array prefix: a example: avalues
Type: Boolean prefix: b Example: Bfound
Type: floating-point prefix: f Example: Fvalue
Type: Function prefix: fn Example: Fnmethod
Type: integer prefix: i example: ivalue
Type: Object prefix: o Example: Otype
Type: Regular prefix: re example: Repatten
Type: String prefix: s example: svalue
Type: Variable prefix: v Example: vvalue
2.3 Key Words
The keywords defined by ECMA-262 are:
Break case Catch Continue default Delete does else finally for function if in instanceof new return switch This throw try typeof var void while with
2.4 Reserved words
The reserved words in the 3rd edition of ECMA-262 are:
Abstract Boolean byte char class const debugger Double enum export extends final float Goto implements Impo RT int interface Long native package private protected public short static super synchronized throws NT volatile
2.5 Original value and reference value
The original value (primitive value) is a simple data segment stored in the stack (stack), that is, their values are stored directly in the location where the variable is accessed.
A reference value (reference value) is an object stored in a heap (heap), meaning that the value stored at the variable is a pointer (point) that points to the memory where the object is stored.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.