Categories
JavaScript Answers

How to fix string.split is not a function with JavaScript?

Spread the love

Sometimes, we want to fix string.split is not a function with JavaScript.

In this article, we’ll look at how to fix string.split is not a function with JavaScript.

How to fix string.split is not a function with JavaScript?

To fix string.split is not a function with JavaScript, we should make sure we’re calling split on a string.

For instance, we write

const string = document.location.toString();

to convert document.location to a string with toString before we call split on it.

Conclusion

To fix string.split is not a function with JavaScript, we should make sure we’re calling split on a string.

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 *