Array Array Object

Last updated: 2026-09-09

Array Array Object

Array is JavaScript's built-in array object: a constructor for ordered lists with 30+ methods for adding, removing, searching, iterating and transforming. Arrays are untyped — any mix of values is allowed and length is maintained automatically.

CategoryArrays
ES versionES1 (1997)

📝 Syntax

const arr = [1, 2, 3];                 // literal (preferred)
const arr = new Array(3);               // [empty × 3] careful
const arr = new Array(1, 2, 3);         // [1, 2, 3]
Array.isArray(arr);                     // true

▶ Example

Edit the code, press Run, and see the result in the output panel:

Output:

3
[ 10, 30, 50 ]
⚠️ Warning new Array(3) creates 3 empty slots, not [3] — a single numeric argument sets the length. Prefer literals.
💡 Tip Arrays are reference types: const arr = [1]; arr.push(2) is legal. Copy with [...arr] or slice().
More case studies coming soon — check back later.

📚 Related Tutorials

❓ FAQ

QHow to check for an array?
AArray.isArray(value) is the only reliable way; typeof gives object and instanceof fails across frames.
QCan length be assigned?
AYes: a smaller value truncates (irreversibly); a larger value creates trailing holes.
QDoes method-chain order matter?
AYes — filter then map differs from map then filter; most methods return new arrays.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏