JavaScript String raw() Method Last Updated : 14 Mar, 2024 Summarize Suggest changes Share Like Article Like Report The raw() method in JavaScript is a template string tag function that returns the raw string form of template literals. It can be used to get the raw string form of a template literal without processing escape sequences. This method is useful when dealing with special characters that should not be escaped. Syntax: String.raw(callSite, ...substitutions) Parameters: This method takes two parameters: Parameter Description callSite An object representing the template string literal. substitutions Optional, values to replace placeholders in the template string. Return Value: Raw string form of the template literal. JavaScript String raw() Method ExamplesExample 1: Using String.raw() with template literals Using String.raw() with template literals provides a way to access the raw string form of the template without interpreting escape sequences. Here, String.raw allows the backslashes in the template literal to be preserved as is, producing the raw string "C:\Users\John\Desktop\file.txt". Without String.raw, the backslashes would have been interpreted as escape sequences, leading to unexpected results. JavaScript const path = String.raw`C:\Users\John\Desktop\file.txt`; console.log(path); OutputC:\Users\John\Desktop\file.txt Example 2: Escaping in String.raw() In JavaScript, String.raw() is used to produce a raw string from template literals. This means that escape sequences such as \n or \t are not interpreted as newline or tab characters. Here, String.raw() produces a raw string where the \n sequence is not interpreted as a newline character but instead remains as literal characters \ and n. JavaScript const str = String.raw`First line\nSecond line`; console.log(str); OutputFirst line\nSecond line Supported Browsers: Google ChromeEdge FirefoxOperaSafariWe have a complete list of Javascript string methods, to check those please go through this Javascript String reference article. Advertise with us Next Article String Handling with Apache Commons' StringUtils Class in Java S shobhit_sharma Follow Similar Reads TypeScript String.raw() Method The String.raw() method in TypeScript is used to obtain the raw string representation of template literals without interpreting escape characters. This is particularly useful for preserving escape sequences and special characters.SyntaxString.raw(string: TemplateStringsArray, ...values: any[]): stri 2 min read String Handling with Apache Commons' StringUtils Class in Java The Apache Commons Lang library is a popular third-party library for working with Strings in Java, and the StringUtils class is a key part of this library. StringUtils is a utility class that provides a wide range of String manipulation methods that are not available in the standard Java String clas 9 min read String Class in Java A string is a sequence of characters. In Java, objects of the String class are immutable, which means they cannot be changed once created. In this article, we are going to learn about the String class in Java.Example of String Class in Java:Java// Java Program to Create a String import java.io.*; cl 7 min read DigestInputStream.toString() method in Java with Examples The toString() method of java.security.DigestInputStream class provide the object of DigestInputStream in string format.Syntax: public String toString() Return Value: This method returns the object of DigestInputStream in string format.Note : All the programs in this article wonât run on online IDE 2 min read Java String Manipulation: Best Practices For Clean Code In Java, a string is an object that represents a sequence of characters. It is a widely used data type for storing and manipulating textual data. The String class in Java is provided as a part of the Java standard library and offers various methods to perform operations on strings. Strings are funda 7 min read String toString() Method in java with Examples String toString() is the built-in method of java.lang which return itself a string. So here no actual conversion is performed. Since toString() method simply returns the current string without any changes, there is no need to call the string explicitly, it is usually called implicitly. Syntax : publ 1 min read Article Tags : JavaScript Web Technologies Like