js|js 内存图

var a = { name: 'a'} var b = a b.name = 'b' a.name = 'b'

Stack Heap
a ADDR 101 101:name:'a' -> 'b'
b ADDR 101
var a = 1 var b = a b = 2 a = 1

Stack Heap
a 1
b 1 -> 2
var a = { name: 'a'} var b = a b ={name: 'b'} a .name= 'a'

Stack Heap
a ADDR 101 101:name:'a' -> 'b'
b ADDR 101 -> 102 102:name:'b'
var a = { name: 'a'} var b = a b =null a .name= 'a'

Stack Heap
a ADDR 101 101:name:'a' -> 'b'
b ADDR 101 -> null
var a = {} a.self = a a.self.self.self=?

Stack Heap
a ADDR 101 101:name:'a' -> 'b' + self:ADDR 101
var a = {n:1} var b = a a.x = a = {n: 2} alert(a.x); // --> undefined alert(b.x); // --> [object Object]

Stack Heap
a ADDR 101 ->102 101:n:1 + ADDR102
b ADDR 101 102:n:2
7.垃圾回收
var a = {name: 'a '} var b = {name: 'b'} a = b

Stack Heap
a ADDR 101 ->102 101:name: 'a' ->垃圾回收
b ADDR 102 102:name:'b'
【js|js 内存图】参考教程饥人谷

    推荐阅读