The difference between a JavaScript reference type and a base type

Source: Internet
Author: User

JavaScript variables can be used to hold two types of values: the base type value and the reference type value.

There are 5 types of base type values: Undefined,null,boolean,number,string

There are two types of reference type values: Functions, objects.

Characteristics of base type values and reference type values:

1, the basic type value in memory occupies a fixed size of space, so is stored in the stack memory;

2, from one variable to another copy of the basic type of value, will create this worth a copy;

3, the value of the reference type is an object, stored in the heap memory;

4. A variable containing a value of a reference type actually contains not the object province, but a pointer to the object;

5. The value of the copied reference type from one variable to another, and the pointer is copied, so two variables end up pointing to the same object;

6. Determine which base type a value can use the TypeOf operator, and determine which reference type can use the instanceof operator.

The difference between a JavaScript reference type and a base type

Related 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.