Skip to content

Latest commit

 

History

History
71 lines (58 loc) · 1.74 KB

File metadata and controls

71 lines (58 loc) · 1.74 KB
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
devlang-javascript
language-reference
JavaScript
TypeScript
DHTML
b1038b73-3944-4645-b075-3a674b313762
3
mikejo5000
mikejo
ghogen

String.raw Function (JavaScript)

Returns the raw string form of a template string.

Syntax

String.raw`templateStr`;  
String.raw(obj, ...substitutions);  

Parameters

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.

Remarks

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.

Example

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   

Requirements

[!INCLUDEjsv12]