Categories
JavaScript Answers

How to remove double quotes from default string with JavaScript?

Spread the love

Sometimes, we want to remove double quotes from default string with JavaScript.

In this article, we’ll look at how to remove double quotes from default string with JavaScript.

How to remove double quotes from default string with JavaScript?

To remove double quotes from default string with JavaScript, we can use the string replace method.

For instance, we write:

const test = "\"House\"";
const s = test.replace(/\"/g, "");
console.log(s)

to call test.replace with /\"/g and an empty string to replace all double quotes with empty strings.

Therefore, s is 'House'.

Conclusion

To remove double quotes from default string with JavaScript, we can use the string replace method.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *