Get to know MDN better
This page was translated from English by the community. Learn more and join the MDN Web Docs community.
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015년 9월.
String.raw()메서드는 템플릿 리터럴의 태그 함수입니다. 이는 Pyhon의 r 접두사 또는 C#의 문자열 리터럴의 @ 접두사와 유사합니다.(그러나 동일 하지는 않습니다. 이 문제에 관해서는 여기 이슈를 참조하십시오.) 이 메서드는 템플릿 리터럴의 윈시 문자열을 가져오는데 사용됩니다. 즉, 대체(예: ${foo})는 처리되지만 이스케이프(예: \n)는 처리되지 않습니다.
정해진 형식의 템플릿 호출 개체 예: { raw: ['foo', 'bar', 'baz'] }.
...substitutions대체값을 포함합니다.
templateString템플릿 리터럴, 선택사항으로 대체를 포함 예:(${...}).
주어진 템플릿 리터럴의 원시 문자열 형식.
첫번째 인자의 객체의 포맷이 올바르지 않은 경우 TypeError예외가 발생(throw)한다.
String.raw()의 경우 보통 템플릿 리터럴과 많이 사용하고, 첫번째 구문의 경우 잘 사용되지 않습니다. 왜냐하면 JavaScript 엔진이 당신을 위해서 자동으로 적절한 인수로 호출해주기 때문입니다. ( 다른 태그 메서드 들과 마찬가지로).
String.raw()은 템플릿 리터럴의 유일한 내장 함수입니다. 기본 템플릿 기능과 동일하게 작동하며 연결을 수행합니다. JavaScript 코드를 사용하여 다시 구현할 수도 있습니다.
| ECMAScript® 2027 Language Specification # sec-string.raw |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2025년 2월 11일 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.