Front-End Questions-JS Chapter

Source: Internet
Author: User

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

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.