String Processing in JavaScript (Part 2)

Tram Ho

Hi guys, following the topic of string handling in JS, today I will continue to introduce methods commonly used when working with string data that devjs cannot ignore. Let’s start

11. String.prototype.split ()

As the name implies, split() splits a string into an ordered list of substring, places the substring in an array and returns the array.

Syntax

12. String.prototype.substring ()

The substring() returns the part of the string between the beginning and the end of the string, or the end of the string

Syntax

13. String.prototype.toString ()

The toString() returns a string representing the specified object

Syntax

14. String.prototype.toLowerCase ()

The toLowerCase() returns a string converted to lowercase

Syntax

15. String.prototype.toUpperCase ()

The toUpperCase() returns a toUpperCase() string

16. String.prototype.trim ()

The trim() removes spaces from both ends of a string. Whitespace in this context is all space characters (spaces, tabs, nonbreaking spaces, etc.) and all line-ending characters (LF, CR, etc.).

Syntax

17. String.prototype.trimEnd ()

The trimEnd() removes spaces at the end of the string

Syntax

18. String.prototype.trimStart ()

The trimStart() removes spaces at the end of the string

Syntax

19. String.prototype.valueOf ()

The valueOf() returns a primitive value of a string object

Syntax

Conclude

Above I have introduced to you most of the common methods when manipulating String data, hoping to be useful for you in the working process.

If you find a good article, give me +1 upvote. If you like me, please press the follow button for more interesting things. Good luck !

Share the news now

Source : Viblo