1.Naming of variables
Naming method (camel nomenclature)
All lowercase: All underscores between words (my_namespace)
Case mix: The first word is lowercase and the first letter is uppercase.
rule
First character English letters or underscores
Composition of English alphanumeric underline
Taboo JavaScript keyword reserved words
2. Variable declaration
Display statement: var keyword
Bad habit: no type repeated declaration implicit declaration without declaration direct assignment
Correct solution: Declare first, then read and write first, assign value first, then calculate
3. Variable Type
Value Type
A) Fixed space stored in the stack
B) The value itself is saved and assigned
C) Use typeof to detect the type of data
D) The basic type data is a value type
Reference Type
A) The space is not fixed and stored in the heap
B) Save and copy a pointer to the object
C) Use instanceof to detect the type of data
D) The object constructed using the new() method is a reference type
4. Variable scope
Global variables contain variables defined outside the function body without var. It is not recommended to use (can be called at any location)
Local variables contain parameter variables of variable functions declared using var inside the function body (inside the current function body)
Scope chain: Inner function can access local variables of outer function
Outer functions cannot access local variables of inner function
Lifecycle: Global variables exist unless they are displayed and deleted.
Local variables are deleted from the time they are declared until the function is completed or displayed.
Recycling mechanism mark clear reference count
The above comprehensive understanding of js variables for learning native javascript is the entire content that the editor has shared with you. I hope you can give you a reference and I hope you can support Wulin.com more.