0% found this document useful (0 votes)
3 views1 page

Stack vs Heap in JavaScript Objects

Const can change object properties but not reassign objects, as objects are stored by reference on the heap rather than value on the stack. Const prevents reassigning a variable but not mutating an object. Object.assign only does a shallow copy for nested objects.

Uploaded by

Josip Pavic
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Stack vs Heap in JavaScript Objects

Const can change object properties but not reassign objects, as objects are stored by reference on the heap rather than value on the stack. Const prevents reassigning a variable but not mutating an object. Object.assign only does a shallow copy for nested objects.

Uploaded by

Josip Pavic
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

const value works only for prim types ,but if we reate object with const

we will be able to change object properties values.


This is beacouse we dont change value on stack, ve change only value on
heap. But we cant change object with const to anouther object
Ex const jesica={ name="j"} const jm=jessica jm={} this wont work
,it will onli work if we use let variable let jm=jessica jm{}.
[Link] radi samo na prvom levelu tj shallow copy ako imamo objekt u objektu
ne radi.

You might also like