Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array Question #1

Open
koakumaping opened this issue Jun 8, 2017 · 2 comments
Open

Array Question #1

koakumaping opened this issue Jun 8, 2017 · 2 comments

Comments

@koakumaping
Copy link

koakumaping commented Jun 8, 2017

var a = [1, 2, 3]
var b = [1, 2, 3, 4]
a = b
a.reverse()

console.log(b)
@BarryZhan
Copy link

[4, 3, 2, 1]

@Da-Sheng
Copy link

Da-Sheng commented Jun 9, 2017

有两个数组对象[1, 2, 3],[1, 2, 3, 4],
a = b, 将变量a指向[1, 2, 3, 4], b也指向这一个数组,
a.reverse()操作堆内存中的数组,输出b的时候变化也会显现出来。
[1, 2, 3]如果没有其他引用的话,垃圾回收会清掉它。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants