javascript - Will variables defined as undefined in JS occupy memory?
ringa_lee
ringa_lee 2017-05-19 10:14:18
0
1
893
let x = {
    'a' = 123
}

let y = {
    'a' = 123,
    'b' = undefined
}
let z = undefined;

如上,y会比x占用内存多么,z会占用内存么?
ringa_lee
ringa_lee

ringa_lee

reply all(1)
我想大声告诉你

undefined occupies memory, has a fixed size, and is stored in the stack area, so z occupies memory. xy objects exist in the heap area, and their memory addresses are stored in stack memory. Because y has more undefined, it occupies more heap memory than x.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template