| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Errors/Invalid_array_length | [Back] [Original] |
Get to know MDN better
This page was translated from English by the community. Learn more and join the MDN Web Docs community.
RangeError: invalid array length (Firefox) RangeError: Invalid array length (Chrome) RangeError: Invalid array buffer length (Chrome)
RangeError
, :
Array ArrayBuffer, , 232, Array.length , 232. length Array ArrayBuffer 32- (integer), 0 232-1.
(new Array()) , . , , length .
new Array(Math.pow(2, 40));
new Array(-1);
new ArrayBuffer(Math.pow(2, 32));
new ArrayBuffer(-1);
let a = [];
a.length = a.length - 1; // -1
let b = new Array(Math.pow(2, 32) - 1);
b.length = b.length + 1; // 2^32
[Math.pow(2, 40)]; // [ 1099511627776 ]
[-1]; // [ -1 ]
new ArrayBuffer(Math.pow(2, 32) - 1);
new ArrayBuffer(0);
let a = [];
a.length = Math.max(0, a.length - 1);
let b = new Array(Math.pow(2, 32) - 1);
b.length = Math.min(0xffffffff, b.length + 1);
// 0xffffffff
// 2^32 - 1, (-1 >>> 0)
This page was last modified on 7 . 2023 . by MDN contributors.
Your blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |