I have a JS array which each key of it contains the whole HTML of a page. I use that array as a back and forward button.
Sometimes when it contains the HTML of 100 pages, the performance of the browser will drop. Well I have two questions:
- Is it possible to I calculate the size of a JS array on the memory?
- How can I limit an array? I mean, I want to remove old array's values when I push new values. Something example blow.
Current array:
var myarr = ['val1', 'val2', 'val3']; // - it should be limited to 3 values
+------+------+------+
| val1 | val2 | val3 |
+------+------+------+
Expected array after pushing a new value into it:
myarr.push('val4'); // expected result:
+------+------+------+
| val2 | val3 | val4 |
+------+------+------+
Is doing that possible?