i m confused working with javascript arrays
This question already has an answer here:
y[..] = ... is modifying an existing object. That change is visible to anything that holds a reference to that object.
y = ... assigns an entirely new value to the local y variable and discards the previously assigned object reference. That change is not visible outside the function since nothing else has access to the y variable.
