| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/String/raw | [Back] [Original] |
Get to know MDN better
// Windows
const filePath = String.raw`C:\Development\profile\about.html`;
console.log(`The file was uploaded from: ${filePath}`);
// : "The file was uploaded from: C:\Development\profile\about.html"
String.raw(strings)
String.raw(strings, sub1)
String.raw(strings, sub1, sub2)
String.raw(strings, sub1, sub2, /* , */ subN)
String.raw`templateString`
strings { raw: ['foo', 'bar', 'baz'] } raw
sub1, , subNtemplateStringTypeError 1 raw raw undefined null
String.raw() JavaScript
String.raw() raw length length "" substitutions.length < strings.raw.length - 1 -
String.raw`Hi\n${2 + 3}!`;
// 'Hi\\n5!' 'Hi'
//
// '\' 'n' 2
String.raw`Hi\u000A!`;
// 'Hi\\u000A!'
// \, u, 0, 0, 0, A, 6
//
//
// .length
const name = "Bob";
String.raw`Hi\n${name}!`;
// 'Hi\\nBob!'
String.raw`Hi \${name}!`;
// 'Hi \\${name}!'
String.raw RegExp()
(\\) URL
// String.raw URL
const reRawTemplate = new RegExp(
String.raw`https://developer\.mozilla\.org/en-US/docs/Web/JavaScript/Reference/`,
);
//
// \/
const reRegexpLiteral =
/https:\/\/developer\.mozilla\.org\/en-US\/docs\/Web\/JavaScript\/Reference\//;
// RegExp \\.
//
const reStringLiteral = new RegExp(
"https://developer\\.mozilla\\.org/en-US/docs/Web/JavaScript/Reference/",
);
// String.raw
function makeURLRegExp(path) {
return new RegExp(String.raw`https://developer\.mozilla\.org/${path}`);
}
const reDynamic = makeURLRegExp("en-US/docs/Web/JavaScript/Reference/");
const reWildcard = makeURLRegExp(".*");
// HTML
const doc = html`<!doctype html>
<html lang="en-US">
<head>
<title>Hello</title>
</head>
<body>
<h1>Hello world!</h1>
</body>
</html>`;
html
const html = String.raw;
String.raw "cooked"
const doc = html`<canvas>\n</canvas>`;
// "<canvas>\\n</canvas>"
"cooked" String.raw
const html = (strings, ...values) => String.raw({ raw: strings }, ...values);
// HTML
const doc = html`<canvas>\n</canvas>`;
// "<canvas>\n</canvas>"; "\n"
raw length raw 'test' ['t', 'e', 's', 't'] `t${0}e${1}s${2}t`
String.raw({ raw: "test" }, 0, 1, 2); // 't0e1s2t'
| ECMAScript 2027 LanguageSpecification # sec-string.raw |
Stringanchor()at()big()blink()bold()charAt()charCodeAt()codePointAt()concat()endsWith()fixed()fontcolor()fontsize()includes()indexOf()isWellFormed()italics()lastIndexOf()link()localeCompare()match()matchAll()normalize()padEnd()padStart()repeat()replace()replaceAll()search()slice()small()split()startsWith()strike()sub()substr()substring()sup()toLocaleLowerCase()toLocaleUpperCase()toLowerCase()toString()toUpperCase()toWellFormed()trim()trimEnd()trimStart()valueOf()[Symbol.iterator]()Object/Function| Web Proxy Viewer | New URL | Original Page |