String.raw(callSite, ...substitutions) String.rawtemplateString
인자
callSite
Well-formed template call site object, like
{ raw: ['foo', 'bar', 'baz'] }
....substitutions
Contains substitution values.
templateString
A template literal, optionally with substitutions (
${...}
).console.log(String.raw`Hi\n${2 + 3}!`); // Hi\n5! // '\' 과 'n' 는 각각 한문자로 처리됨 console.log(String.raw`Hi\u000A!`); // 'Hi\u000A!', same here, this time we will get the // \, u, 0, 0, 0, A, 6 characters. let name = "Bob"; console.log(String.raw`Hi\n${name}!`); // 'Hi\nBob!', substitutions are processed. // 일반적으로 이걸 함수로 쓰진 않긴함. // but to simulate `foo${2 + 3}bar${'Java' + 'Script'}baz` you can do: console.log( 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`: console.log(String.raw({ raw: "test" }, 0, 1, 2)); // 't0e1s2t'