Home > Web Front-end > Front-end Q&A > Does javascript have a constant pool?

Does javascript have a constant pool?

WBOY
Release: 2022-06-16 17:02:40
Original
1994 people have browsed it

There is a constant pool in JavaScript; the memory space of JavaScript is divided into stack, heap, pool, and queue. The pool refers to the constant pool. The constant value is the basic data type used to store constants. Generally, the constant pool is Classified into stack memory, the data types in the constant pool occupy less space, have a fixed size, and are frequently used, so the system efficiency is high.

Does javascript have a constant pool?

The operating environment of this tutorial: Windows 10 system, JavaScript version 1.8.5, Dell G3 computer.

Does javascript have a constant pool?

javascript has a constant pool

JavaScript memory space is divided into: stack, heap, pool, and queue.

Stack memory: used to store basic data types

Constant pool: used to store constant basic data types (generally classified into stack memory)

Heap memory: used to store reference data types

When the variable stores the basic data type, the value of the variable is stored in the stack memory

When the variable stores a reference data type, the variable value stores a memory address allocated by the system, while the real reference data type is stored in the heap memory, and the memory address points to the reference data type in the heap memory

Stack memory

Take the numerical type (Number), one of the basic data types, as an example:

When we declare a basic data type variable, it will be in the stack memory Store variable names and specific values

Does javascript have a constant pool?

When we use console.log(a), we output the corresponding value

Extension:

Heap memory

For example

let a={1,2,3}
let b={m:20}
Copy after login

Does javascript have a constant pool?

We can see from the above picture that variable a1 is the basic Data type, and variables b and c are reference number types. What b and c store in the stack is not the value of the variable, but a memory reference address allocated by the system. The real data is stored in the heap content

When we declare a variable to store a reference data type, a variable name and a specific value will be generated in the stack memory, and this specific value is a memory reference address allocated by the system. This address points to the memory stored in the heap memory. The reference data type created. When we call the variable, the parser will reference the corresponding object based on the reference address corresponding to the variable.

【Related recommendations: javascript video tutorial, web front-end

The above is the detailed content of Does javascript have a constant pool?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template