Error.prototype.name
Properti name
menyatakan nama dari jenis error. Nilai awalnya adalah "Error".
Deskripsi
Secara default, misalnya Error
diberi nama "Error". Properti name
, sebagai tambahan utuk properti message
(en-US), digunakan oleh method Error.prototype.toString()
(en-US) untuk membuat sebuah pernyataan dalam bentuk string yang menyatakan error.
Contoh
Menggunakan custom error
var e = new Error('Inputan tidak lengkap'); // e.name nilainya 'Error'
e.name = 'ParseError';
throw e;
// e.toString() akan mengembalikan 'ParseError: Inputan tidak lengkap'
Spesifikasi
Spesifikasi | Status | Comment |
---|---|---|
ECMAScript 1st Edition (ECMA-262) | Standard | Initial definition. |
ECMAScript 5.1 (ECMA-262) The definition of 'Error.prototype.name' in that specification. |
Standard | |
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Error.prototype.name' in that specification. |
Standard | |
ECMAScript (ECMA-262) The definition of 'Error.prototype.name' in that specification. |
Living Standard |
Kompabilitas browser
We're converting our compatibility data into a machine-readable JSON format.
This compatibility table still uses the old format,
because we haven't yet converted the data it contains.
Find out how you can help! (en-US)
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |