How does JavaScript store empty values ​​inside?

I always wondered how JavaScript stores null values ​​inside. null is different from any value. I believe that variable regions are stored in some sort of array of structures, each of which corresponds to a variable. Does this structure have some kind of logical property called "null"?

I would look for it myself in the V8 source code, but I pretty much lost the C ++ code: (

I did not find anything on Google. Most of the results were related to questions such as "How to determine if a variable is undefined or null?" or similar.

+6
source share
1 answer

JavaScript, a weakly typed scripting language, probably has a variant type that supports the values ​​of all types of types. I believe that PHP uses the same type of variables, although they are known in other languages ​​and play an important role in COM automation.

They are mainly structures that contain type and value. The value may be a simple value or a pointer to a larger or more complex value. null is just one of the supported types, in which case the value itself does not play any role.

But since JavaScript knows a lot of interpreters, there is no rule about how it is implemented, and you have nothing to worry about. Usually you only need to know about basic methods like this for mission-critical applications, which in any case should not be written in JavaScript.

+3
source

All Articles