type
What data types are in 1.js and explain the original data types and reference data types
JS has null,undefined, string,number,boolean,object six kinds of data types.
Original data type: null,undefined, String,number,boolean
Reference data type: Object
The difference between the two:
1) values are stored in different ways:
Raw data type: Store variable names and values in stack memory
Reference data type: Stores the variable name in the stack memory, stores the value in heap memory, and stores the address of the value in the stack memory, which points to the value in heap memory.
2) different assignment methods:
Give a variable the value of another variable
If the value is the original data type, the value is generated directly in the stack memory, and the value changes after two variables do not affect each other.
If the value is a reference data type, give the variable is the value address, through this address, the point is actually the same value in the heap memory, a variable to change the value, will directly affect the value of another variable
2. Explain clearly null and undefined
Null indicates that an identity is assigned, and the identity is assigned a null value, and from a logical point of view, anull value represents an empty object pointer ;
Undefined indicates that the identity was declared, but no value was assigned to the identity.
3. How do I copy a value of a reference type?
4. When will JS make implicit type conversion, the result of conversion?
5. What is the type identification method?
TypeOf: Example: (typeof 1 Returns the result: "Number" typeof new Array () returns the result: "Object") recognizes the standard type, except for null. The specific object type is not recognized except for function.
Instanceof: Example: ([] instanceof Array returns result: True ' a ' instanceof String return Result: false) can discriminate built-in object type, cannot judge original type value
Constructor: Example (' 123 '. Constructor = = String return Result: TRUE)
Object.prototype.toString.call: Example (Object.prototype.toString.call (1) Returns the result: "[Object number]") to identify the standard data type and the built-in object type. Custom object type not recognized
prototypes
1. Tell me what prototype is, the understanding of the prototype chain, and when to useprototype
Front-end questions-JS article