built in array already has desired effect: Several methods take as arguments functions to be called back while processing the array. When these methods are called, the length of the array is sampled, and any element added beyond this length from within the callback is not visited. (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)