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月.
* Some parts of this feature may have varying levels of support.
**RangeError**物件在一個給定的值不在允許的集合或範圍內時被作為一個錯誤拋出
可選。具人類可讀性的錯誤說明
fileName可選。包含造成錯誤發生的程式碼的檔案名稱
lineNumber可選。造成錯誤發生的程式碼行號
當試著往一個 function 傳入一個不被其允許的值作為參數時,一個RangeError被拋出。這可在多種情況遭遇到,例如傳入一個不被允許的字串值到 String.prototype.normalize(),或試著透過 Array constructor 用一個不合法的長度來創建一個陣列,或往數值方法像是Number.toExponential()、Number.toFixed()、Number.toPrecision() 傳進糟糕的值。
允許對一個 RangeError 物件增加其屬性。
普遍的 RangeError 自身沒有包含方法,儘管他的確從原型鍊中繼承了一些。
Error message. Inherited from Error.
RangeError.prototype.nameError name. Inherited from Error.
RangeError.prototype.causeError cause. Inherited from Error.
RangeError.prototype.fileNamePath to file that raised this error. Inherited from Error.
RangeError.prototype.lineNumberLine number in file that raised this error. Inherited from Error.
RangeError.prototype.columnNumberColumn number in line that raised this error. Inherited from Error.
RangeError.prototype.stackStack trace. Inherited from Error.
| ECMAScript® 2027 Language Specification # sec-native-error-types-used-in-this-standard-rangeerror |
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.