After looking for a work written by the baptism, feel oneself JS grammar grasp is not very system, today to comb down-variables and operators.
Basic article
and C language differences: is a weakly typed language, the declaration of variables do not need to specify the type, the name of variable names are also different; simple types are different ; types can be converted to each other
1. Naming
is a letter, the beginning of _,$, consisting of numbers, letters, underscores $, not including the key, the case-sensitive string called identifiers ( added the dollar sign, cannot start with a number ).
2. Affirms that
form: Var KeyName; It can be declared when it is initialized with multiple declarations.
Eg:var obj; var arr=[], objarr={};
Note: (1) No declaration type is required, the type is automatically converted according to the program's run. (2) If no definition is used, it will give an error; it is stated that the Undefinedd type is not assigned, and (3) The global variable is not declared with Var, which is analyzed in detail below the global variable.
3. Variable type
Simple Type: boolean string number undefined null
Note the point:
Boolean: The value of True,false is also converted to 0,1 use, isload () ==1;
String: When characters, or strings are string, can be either single or double quotation marks can be var str= ' adafsd ', str2= "abc", other with C language;
Number: denotes integers, decimals, integers include decimal, octal (078), hexadecimal (ox78), numeric constant: (Infinity means positive infinity large NaN means non-numeric)
NULL: is a null type with only one value NULL. indicates no data.
Complex Type: Array object
Array: A type that can be accessed with subscript, such as Var t=[a,b,c]; can be a complex array type: var t=[{a=b},{a2=b}]
Object type, which can represent the object's property-value, key-value pair. Any type can be nested. Access with. To access.
4. Transmit Value and address
When a variable is a simple type, it is passed value, if the variable is a complex variable, it is addressed, and the original object is passed a reference (either a pointer, or an alias, pointing to the memory space of the original object ).
Javascript Basics-Variables & operators