Hi Friends 👋,
Welcome To Infinitbility! ❤️
To make a string empty in javascript, assign the ""
empty string to the variable. it will remove the previous value and store a new value which is a string.
Today, I’m going to show you How do I make a string empty in javascript, as mentioned above, I’m going to create a sample string variable then I will assign an empty string to make the string variable empty.
Let’s start today’s tutorial on how do you make a string empty in javascript.
Javascript makes a string empty
Here, we will do
- Create a sample string variable with data.
- assign an empty string to the variable
// Create sample string variable with data.
let str = "infintbility";
console.log("Result 1: ", str)
// assign an empty string to the variable
str = "";
console.log("Result 2: ", str)
Output
I hope it helps you, All the best 👍.