ReferenceError
Baseline
Widely available
*
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.
ReferenceError ãªãã¸ã§ã¯ãã¯ãç¾å¨ã®ã¹ã³ã¼ãã«åå¨ããªãï¼ãããã¯ã¾ã åæåããã¦ããªãï¼å¤æ°ãåç
§ãããã¨ãã®ã¨ã©ã¼ã表ãã¾ãã
ReferenceError ã¯ã·ãªã¢ã©ã¤ãºå¯è½ãªãã¸ã§ã¯ããªã®ã§ã structuredClone() ã§è¤è£½ããããã¯ã¼ã«ã¼éã§ postMessage() ã使ç¨ãã¦ã³ãã¼ããããããã¨ãã§ãã¾ãã
ReferenceError 㯠Error ã®ãµãã¯ã©ã¹ã§ãã
ã³ã³ã¹ãã©ã¯ã¿ã¼
ReferenceError()-
æ°ãã
ReferenceErrorãªãã¸ã§ã¯ããçæãã¾ãã
ã¤ã³ã¹ã¿ã³ã¹ããããã£
親ã§ãã Error ããç¶æ¿ããããããã£ãããã¾ãã
ãããã®ããããã£ã¯ ReferenceError.prototype ã§å®ç¾©ããã¦ããããã¹ã¦ã® ReferenceError ã¤ã³ã¹ã¿ã³ã¹ã§å
±æããã¾ãã
ReferenceError.prototype.constructor-
ãã®ã¤ã³ã¹ã¿ã³ã¹ãªãã¸ã§ã¯ãã使ããã³ã³ã¹ãã©ã¯ã¿ã¼é¢æ°ã
ReferenceErrorã¤ã³ã¹ã¿ã³ã¹ã®å ´åãåæå¤ã¯ReferenceErrorã³ã³ã¹ãã©ã¯ã¿ã§ãã ReferenceError.prototype.name-
ã¨ã©ã¼åã®ååã表ãã¾ãã
ReferenceError.prototype.nameã®åæå¤ã¯"ReferenceError"ã§ãã
ã¤ã³ã¹ã¿ã³ã¹ã¡ã½ãã
親ã§ãã Error ããç¶æ¿ããã¡ã½ãããããã¾ãã
ä¾
>ReferenceError ã®ææ
try {
let a = undefinedVariable;
} catch (e) {
console.log(e instanceof ReferenceError); // true
console.log(e.message); // "undefinedVariable is not defined"
console.log(e.name); // "ReferenceError"
console.log(e.stack); // ãã®ã¨ã©ã¼ã®ã¹ã¿ãã¯
}
ReferenceError ã®çæ
try {
throw new ReferenceError("Hello");
} catch (e) {
console.log(e instanceof ReferenceError); // true
console.log(e.message); // "Hello"
console.log(e.name); // "ReferenceError"
console.log(e.stack); // ãã®ã¨ã©ã¼ã®ã¹ã¿ãã¯
}
仿§æ¸
| Specification |
|---|
| ECMAScript® 2027 Language Specification> # sec-native-error-types-used-in-this-standard-referenceerror> |