Categories
JavaScript Answers

How to split first name and last name using JavaScript?

Spread the love

Sometimes, we want to split first name and last name using JavaScript.

In this article, we’ll look at how to split first name and last name using JavaScript.

How to split first name and last name using JavaScript?

To split first name and last name using JavaScript, we use the split method.

For instance, we write

const names = "Paul Steve Jones".split(" ");

to call split with ' ' to split the names into an array of name strings.

Conclusion

To split first name and last name using JavaScript, we use the split 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 *