ECMAScript basics, mainly including syntax, variables, keywords, reserved words, original values and reference values, etc. 2.1 syntax
Case-sensitive, weak variable type, line-and-tail semicolons are optional, comments are diagonal lines, and parentheses indicate code blocks.
2.2 Variables
Variables are declared using var. Naming rules for variables: the first character must be a letter, underline, or dollar sign; the remaining characters can be an underscore, dollar sign, or any letter or digit.
Variable naming rules:
Camel markup: the first letter is lowercase, and the subsequent words start with an uppercase letter. For example, var myTestValue = 0, mySecondTestValue = "hi ";
Pascal markup: the first letter is capitalized, and the subsequent words start with an uppercase letter. For example, var MyTestValue = 0, MySecondTestValue = "hi ";
Hungary type labeling: append a lower-case letter (or lower-case letter sequence) to a variable named by Pascal, indicating the type of the variable. For example, I represents an integer, and s represents a string, as shown below:
Var iMyTestValue = 0, sMySecondTestValue = "hi ";
The prefix used to define ECMAScript variables using the Hungary type markup method 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 keywords
The ECMA-262 defines the Keyword:
Break case catch continue default delete do else finally for function if in instanceof new return switch this throw try typeof var void while
2.4 Reserved Words
Reserved Words in ECMA-262 3rd edition:
Abstract boolean byte char class const debugger double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile
2.5 Original Value and reference value
The original value is a simple data segment stored in the stack, that is, their values are directly stored in the access location of the variable.
Reference value is an object stored in heap. That is, the value stored in a variable is a pointer to the memory of the object.
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.