JavaScript basic type and reference type value "JavaScript advanced Programming"

Source: Internet
Author: User

The ECMAScript variable may contain values for two different data types: the base type value and the reference type value.
Primitive type values refer to simple data segments that are stored in the stack's memory, meaning that this value is completely stored in a single location in memory.
The reference type value refers to the object that is stored in the heap memory, meaning that the variable is actually a pointer to another location in memory where the object is saved.
5 Basic data types: Undefined, Null, Boolean, number, and string.
The values of these 5 basic data types occupy a fixed amount of space in memory, so they can be stored in the stack memory.
This can increase the speed of the query. For variables that hold primitive type values, we say that they are accessed by value because we are manipulating the values they actually hold.
If you assign a value to a variable that is a reference type, you must allocate space for the value in heap memory. Because this is not a good size, they cannot be saved to occupy memory.
However, the size of the memory address is fixed, so the memory address can be stored in the stack memory. In this way, when querying a variable of a reference type, you can first read the memory address from the stack and then
"Navigate" to find the value saved in the heap. For this way of querying variable values, we call it access by reference, so we are not manipulating the actual value, but the object referenced by that value.

JavaScript basic type and reference type value "JavaScript advanced Programming"

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.