Властивість message - це зрозумілий людині опис помилки.
Опис
Ця властивість містить стислий опис помилки, якщо він був наданий. Рушій SpiderMonkey активно використовує властивість message для винятків. Властивість message у поєднанні з властивістю name використовується методом Error.prototype.toString() для створення рядкового представлення помилки.
За замовчуванням, властивість message є порожнім рядком, але ця поведінка може бути заміщена, наприклад, передачею повідомлення першим аргументом у конструктор Error.
Приклади
Викидання користувацької помилки
var e = new Error('Could not parse input');
// e.message дорівнює 'Could not parse input'
throw e;
Специфікації
| Специфікація | Статус | Коментар |
|---|---|---|
| ECMAScript 1st Edition (ECMA-262) | Standard | Початкове визначення. |
| ECMAScript 5.1 (ECMA-262) The definition of 'Error.prototype.message' in that specification. |
Standard | |
| ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Error.prototype.message' in that specification. |
Standard | |
| ECMAScript Latest Draft (ECMA-262) The definition of 'Error.prototype.message' in that specification. |
Draft |
Сумісність з веб-переглядачами
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
message | Chrome Full support 1 | Edge Full support 12 | Firefox Full support 1 | IE Full support 6 | Opera Full support Yes | Safari Full support Yes | WebView Android Full support 1 | Chrome Android Full support 18 | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support 1.0 | nodejs Full support Yes |
Legend
- Full support
- Full support