Get to know MDN better
此頁面由社群從英文翻譯而來。了解更多並加入 MDN Web Docs 社群。
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.
unshift() 方法會添加一個或多個元素至陣列的開頭,並且回傳陣列的新長度。
欲添加至陣列開頭的元素。
呼叫此方法之物件的新 length 屬性值。
unshift 方法會將一或多個給定值插入至一個類陣列(array-like)物件的開頭。
unshift 被刻意設計為具通用性;此方法可以藉由 called 或 applied 應用於類似陣列的物件上。若欲應用此方法的物件不包含代表一系列啟始為零之數字屬性序列長度的 length 屬性,可能是不具任何意義的行為。
| ECMAScript® 2027 Language Specification # sec-array.prototype.unshift |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2025年7月14日 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.