Javascript string stored on stack

I am reading Professional JavaScript for web developers 3rd ed. , and in the summary of chapter 4 you can read:

Two types of values ​​can be stored in JavaScript variables: primitive values ​​and reference values. Primitive values ​​have one of five primitive data types: Undefined, Null, Boolean, Number, and String. Primitive and reference values ​​have the following characteristics:

  • Primitive values ​​have a fixed size and therefore are stored in memory on the stack.

But I can have different lines, say:

var a = "ABC";

//or

var b = "Some very annoyingly long string ..."

They obviously vary in size, so how can they be allocated on the stack?

I believe that the same question can be asked by numbers ...

, - .

- , / ?

+4
2

( ) , , .

, , , . - .

JavaScript , -, . JavaScript , .

, , . , , .

+2

.

.

-, , .

-, , "".

-, , "" . , "" - , , , . JS- , . , , , , , , . "" , JS , .

, JS, - . .

+2

Source: https://habr.com/ru/post/1611600/


All Articles