let x = {
'a' = 123
}
let y = {
'a' = 123,
'b' = undefined
}
let z = undefined;
如上,y会比x占用内存多么,z会占用内存么?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
undefined占内存的,且大小固定,保存在栈区,所以z是占内存的。xy对象存在堆区,它们的内存地址保存在栈内存中。y因为多了undefined,所以比x占的堆内存多。