1. Name of variable
Name of method (hump naming method)
All lowercase: All underscores between words and words (my_namespace)
Mixed case: First letter lowercase other words in uppercase.
Rules
First character English letter or underline
Make up an English alphanumeric underline
Taboo JavaScript keyword reserved word
2. Declaration of variables
Display declaration: var keyword
Bad habits: No type duplicate declaration an implicit declaration does not declare a direct assignment
Positive solution: First declare after read and write first assignment after operation
3. Variable type
Value type
A The Occupy space is fixed in the stack
B The value itself is saved and assigned
C) using typeof to detect the type of data
D) Basic type data is a value type
Reference type
A the occupied space is not fixed and stored in the heap
B to save and copy is a pointer to the object
C) using instanceof to detect the type of data
D the object constructed using the new () method is a reference type
4. Variable Scope
Global variables that contain variables defined outside the function body define no var in the function body not recommended (any location can be invoked)
A local variable contains a parameter variable of a variable function declared using var within the body of a function (current function body part)
Scope Chain: Inner function can access outer function local variable
Outer function cannot access inner-layer function local variable
Lifecycle: Global variables exist unless they are displayed or deleted
local variable from declaration to function completed or displayed delete
Recycle mechanism tag Clear reference count
Above the original JavaScript learning JS variable full understanding is a small series to share all the content, hope to give you a reference, but also hope that we support the cloud habitat community.