Primitive values -> primitive types Simple data segments stored on the stack, that is, their values are stored directly at the location where the variable is accessed Dynamic language -> scripting language -> interpreted language -> weakly typed language Static language -> compiled language -> strongly typed language null empty value initialization component function destruction function placeholder Reference Value If a value is of a reference type, its storage is allocated from the heap. Since the size of the reference value will change, it cannot be placed on the stack, otherwise it will slow down the variable search. Instead, the value placed in the variable's stack space is the address where the object is stored on the heap. The address size is fixed, so storing it on the stack has no negative impact on the variable's performance. <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>D1</title> </head> <body> <script type="text/javascript"> var arr1 = [1,2,3,4]; var arr2 = arr1; //arr1.push(5); //At this time, arr2 is printed as 1, 2, 3, 4, 5 arr1 = [1,2]; //Reassigning value will not affect arr2 document.write(arr2); </script> </body> </html> This is the end of this article about JS original value and reference value. For more relevant JS original value and reference value content, please search 123WORDPRESS.COM’s previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Introduction to vim plugin installation under Linux system
>>: How to change the color of the entire row (tr) when the mouse stops in HTML
This article shares the specific code for impleme...
When the DataSource property of a DataGrid control...
1. Browser rendering mode and doctype Some web pa...
First look at the effect: When the mouse moves ov...
Antd+react+webpack is often the standard combinat...
This article example shares the specific code for...
Mysql converts query result set into JSON data Pr...
In this article, we will need to learn how to vie...
Preface This article is quite detailed and even a...
Preface Everyone knows how to run a jar package o...
Preface View is a very useful database object in ...
Table of contents Introduction Log classification...
In fact, it is not difficult to build an Apache c...
Table of contents Environmental Description Insta...
Carousel The main idea is: In the large container...