Baseline Widely available
String.raw()
ë©ìëë í
í릿 리í°ë´ì íê·¸ í¨ìì
ëë¤. ì´ë Pyhonì r
ì ëì¬ ëë C#ì 문ìì´ ë¦¬í°ë´ì @
ì ëì¬ì ì ì¬í©ëë¤.(ê·¸ë¬ë ëì¼ íì§ë ììµëë¤. ì´ ë¬¸ì ì ê´í´ìë ì¬ê¸° ì´ì를 참조íììì¤.) ì´ ë©ìëë í
í릿 리í°ë´ì ìì 문ìì´ì ê°ì ¸ì¤ëë° ì¬ì©ë©ëë¤. ì¦, ëì²´(ì: ${foo}
)ë ì²ë¦¬ëì§ë§ ì´ì¤ì¼ì´í(ì: \n
)ë ì²ë¦¬ëì§ ììµëë¤.
// Create a variable that uses a Windows
// path without escaping the backslashes:
const filePath = String.raw`C:\Development\profile\aboutme.html`;
console.log(`The file was uploaded from: ${filePath}`);
// Expected output: "The file was uploaded from: C:\Development\profile\aboutme.html"
구문
String.raw(callSite, ...substitutions);
String.raw`templateString`;
매ê°ë³ì
callSite
ì í´ì§ íìì í
í릿 í¸ì¶ ê°ì²´ ì: { raw: ['foo', 'bar', 'baz'] }
.
...substitutions
ëì²´ê°ì í¬í¨í©ëë¤.
templateString
í
í릿 리í°ë´, ì íì¬íì¼ë¡ ë체를 í¬í¨ ì:(${...}
).
주ì´ì§ í í릿 리í°ë´ì ìì 문ìì´ íì.
ìì¸TypeError
첫ë²ì§¸ ì¸ìì ê°ì²´ì í¬ë§·ì´ ì¬ë°ë¥´ì§ ìì ê²½ì° TypeError
ìì¸ê° ë°ì(throw)íë¤.
String.raw()
ì ê²½ì° ë³´íµ í
í릿 리í°ë´ê³¼ ë§ì´ ì¬ì©íê³ , 첫ë²ì§¸ 구문ì ê²½ì° ì ì¬ì©ëì§ ììµëë¤. ìëíë©´ JavaScript ìì§ì´ ë¹ì ì ìí´ì ìëì¼ë¡ ì ì í ì¸ìë¡ í¸ì¶í´ì£¼ê¸° ë문ì
ëë¤. ( ë¤ë¥¸ íê·¸ ë©ìë ë¤ê³¼ ë§ì°¬ê°ì§ë¡).
String.raw()
ì í
í릿 리í°ë´ì ì ì¼í ë´ì¥ í¨ìì
ëë¤. 기본 í
í릿 기ë¥ê³¼ ëì¼íê² ìëíë©° ì°ê²°ì ìíí©ëë¤. JavaScript ì½ë를 ì¬ì©íì¬ ë¤ì 구íí ìë ììµëë¤.
String.raw`Hi\n${2 + 3}!`;
// 'Hi\\n5!', the character after 'Hi'
// is not a newline character,
// '\' and 'n' are two characters.
String.raw`Hi\u000A!`;
// 'Hi\\u000A!', same here, this time we will get the
// \, u, 0, 0, 0, A, 6 characters.
// All kinds of escape characters will be ineffective
// and backslashes will be present in the output string.
// You can confirm this by checking the .length property
// of the string.
let name = "Bob";
String.raw`Hi\n${name}!`;
// 'Hi\\nBob!', substitutions are processed.
// Normally you would not call String.raw() as a function,
// but to simulate `foo${2 + 3}bar${'Java' + 'Script'}baz` you can do:
String.raw(
{
raw: ["foo", "bar", "baz"],
},
2 + 3,
"Java" + "Script",
); // 'foo5barJavaScriptbaz'
// Notice the first argument is an object with a 'raw' property,
// whose value is an iterable representing the separated strings
// in the template literal.
// The rest of the arguments are the substitutions.
// The first argumentâs 'raw' value can be any iterable, even a string!
// For example, 'test' is treated as ['t', 'e', 's', 't'].
// The following is equivalent to
// `t${0}e${1}s${2}t`:
String.raw({ raw: "test" }, 0, 1, 2); // 't0e1s2t'
ëª
ì¸ ë¸ë¼ì°ì í¸íì± ê°ì´ 보기
String.raw
ì í´ë¦¬íì ì¬ê¸°ë¥¼ ì°¸ê³ core-js
String
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4