By using String Object
This method takes in arguments and creates a new String object.
Syntax:
let stringobject = new String('literal');
Example:
Javascript
let n = 3457554 let str = new String(n) console.log(str) let str1 = new String( 'JavaScript' ); console.log(str1); |
Output
[String: '3457554'] [String: 'JavaScript']
ES6 String
ES6 string is an object that is used to represent a sequence of characters or manipulate the character’s sequence and It can contain zero or more characters within quotes. The text within the single or double quotes is called a string in Javascript.