Suppose getLargeArray()
returns a very large array of many items. I declared a variable called "items" and initialize it with a very large array. Then, I reassign a small array to the variable, items
, like the following:
var items = getLargeArray();
items = ["dog","cat","pig"];
What will happen to the memory that stores the large array? Does items
points to the memory that holds the data? Or, is it a pointer to the address that holds the first element of the array? If I keep doing that, what will happen to my application on Chrome?