Get the App
SLTechnology News&Howtos  ›  Development  › 

How to understand the original value and reference value of JS

Shulou Source: shulou.com Published: 2022-06-02 05:13:07 09月22日 Update

This article mainly introduces "how to understand the original value and reference value of JS". In daily operation, I believe many people have doubts about how to understand the original value and reference value of JS. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubt of "how to understand the original value and reference value of JS". Next, please follow the editor to study!

Original value-> basic type

Number String Boolean undefined null

Simple segments of data stored in the stack, that is, their values are stored directly in the location where the variable is accessed

Dynamic language-> scripting language-> interpretive language-> weakly typed language

Static language-> compiled language-> strongly typed language

Null null initialization component function destroys function occupies space

Reference value

Object array function date RegExp

If a value is of a reference type, its storage space is allocated from the heap. Because the size of the reference value changes, it cannot be placed on the stack, otherwise it will slow down the speed of variable lookup. Instead, the value placed in the stack space of the variable is the address where the object is stored in the heap. The size of the address is fixed, so storing it on the stack does not have any negative impact on variable performance.

Ex

D1 var arr1 = [1jin2jin3 var arr1 4]; var arr2 = arr1; / / arr1.push (5); / / print arr2 as 1jing2jing3 arr1 = [1jing2]; / / re-assign will not affect arr2 [xss_clean] (arr2); at this point, the study on "how to understand the original values and reference values of JS" is over, hoping to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Language primitive storage variables types learning functions addresses size more space help influence utility and then that is location dynamics objects Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL MariaDB OPPO Reno Linux vpn