Why does reference = null not affect the referenced object?
问题 I know this works, but I don't know why or the reasoning behind why it was made to work this way: var foo = [5, 10]; var bar = foo; console.log(foo); //[5, 10] console.log(bar); //[5, 10] bar[0] = 1; console.log(foo); //[1, 10] bar = null; console.log(foo); //[1, 10] I would have expected not just bar to become null, but foo as well. I'd love some help understanding this. 回答1: The difference is between rebinding and mutating operations. bar[0] = 1 is mutating; it affects the object that bar