Memory Usage Of Different Data Types in javascript

后端 未结 2 1829
孤独总比滥情好
孤独总比滥情好 2020-12-15 04:23

A question that has happened to me is that different Data type in javascript how many use of memory . for Example in C++ data type like int , char , float uses order 2 , 1 ,

2条回答
  •  感动是毒
    2020-12-15 04:40

    As of today, MDN Data Structures page gives some more info about it:

    Number

    According to the ECMAScript standard, there is only one number type: the double-precision 64-bit binary format IEEE 754 value

    So that should amount to 8 bytes.

    String

    JavaScript's String type is used to represent textual data. It is a set of "elements" of 16-bit unsigned integer values.

    So that should amount to 2 bytes per character.

    Boolean

    Boolean represents a logical entity and can have two values: true, and false.

    Nothing more about that.

提交回复
热议问题