This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

Error: message

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월⁩.

Error 인스턴스의 message 데이터 속성은 사람이 읽을 수 있는 오류의 설명입니다.

Error() 생성자에 첫 번째 인수로 전달된 값에 해당하는 문자열.

Property attributes of Error: message
쓰기 가능가능
열거 가능불가능
설정 가능가능

설명

이 속성은 오류가 있거나 설정된 경우 오류에 대한 간략한 설명을 포함합니다. name 속성과 결합된 message 속성은 Error.prototype.toString()메서드에서 오류의 문자열 표현을 생성하는 데 사용됩니다.

기본적으로 message 속성은 빈 문자열이지만, Error 생성자에 대한 첫 번째 인수로 메시지를 지정하여 인스턴스에 대해 이 동작을 재정의할 수 있습니다.

예제

사용자 정의 오류 발생시키기

js
var e = new Error("Could not parse input");
// e.message is 'Could not parse input'
throw e;

명세

Specification
ECMAScript® 2026 Language Specification
# sec-error.prototype.message

브라우저 호환성

같이 보기