| title | ms.custom | ms.date | ms.prod | ms.reviewer | ms.suite | ms.technology | ms.tgt_pltfrm | ms.topic | dev_langs | ms.assetid | caps.latest.revision | author | ms.author | manager | ||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
String.raw Function (JavaScript) | Microsoft Docs |
01/18/2017 |
windows-client-threshold |
|
language-reference |
|
b1038b73-3944-4645-b075-3a674b313762 |
3 |
mikejo5000 |
mikejo |
ghogen |
Returns the raw string form of a template string.
String.raw`templateStr`;
String.raw(obj, ...substitutions);
templateStr
Required. The template string.
obj
Required. A well-formed object specified using object literal notation, such as { raw: 'value' }.
...substitutions
Optional. An array (a rest parameter) consisting of one or more substitution values.
The String.raw function is intended for use with template strings. The raw string will include any escape characters and backslashes that are present in the string.
An error is thrown if obj is not a well-formed object.
function log(arg) {
if(console && console.log) {
console.log(arg);
}
};
var name = "bob";
log(`hello \t${name}`);
log(String.raw`hello \t${name}`);
// The following usage for String.raw is supported but
// is not typical.
log(String.raw({ raw: 'fred'}, 'F', 'R', 'E'));
// Output:
// hello bob
// hello \tbob
// fFrReEd
[!INCLUDEjsv12]