String.raw
A template literal without escape-sequence processing.
Available since: ES2015
Syntax
String.raw`text`Return value
stringA string in which backslashes are not processed.
Examples
Backslashes stay as they are:
console.log(String.raw`C:\new\table`);
console.log('C:\\new\\table');Output:
C:\new\table
C:\new\tableSubstitutions still work:
const folder = 'docs';
console.log(String.raw`${folder}\new\file.txt`);Output:
docs\new\file.txtNotes
It is a tag for a template literal: the backticks follow String.raw directly, without parentheses. Handy for Windows paths and regular expressions.
See also
- Template literal — A string in backticks with substitutions and line breaks.
- RegExp — A regular expression — a pattern for finding and replacing text.
In the tutorial
- Template literals — Template literals in JavaScript: inserting values and expressions, multi-line text, conditions inside a template and tagged templates.