JavaScript – Create Empty String

To create an empty string in JavaScript, do not provide any value in double quotes, single quotes, or back-ticks. Or, we can also use String() constructor and pass no parameter in the constructor call.

Examples

The following are some of the quick examples to create an empty string in JavaScript.

var str1 = '';
var str2 = "";
var str3 = ``;
var str4 = new String();

In the following program, we create an empty string in JavaScript, and display this string in a div.

index.html

ADVERTISEMENT

Conclusion

In this JavaScript Tutorial, we learned how to create an empty string in JavaScript, in different ways, with examples.