I've met a problem in learning javascript.Here is my code:
var arr = [];
for (let i = 0; i <4294967296; i=i+1){
arr[i] = 1;}
But both in chrome and firefox,it ended up with something wrong.I know that the max length of an array is 4294967295(2^32-1) in javascript,when i changed 4294967296 to 4294967295, 4294967294 , or a little more smaller,it still didn't work.I also tested it in Node.js,after a while of executing,it just ended with:
FATAL ERROR: invalid array length Allocation failed - JavaScript heap out of memory
I don't know why?