Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How does JavaScript use the split () method

Shulou Source: shulou.com Published: 2022-05-31 11:53:29 09月28日 Update

This article mainly introduces the relevant knowledge of "how JavaScript uses split () method". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how JavaScript uses split () method" can help you solve the problem.

JavaScript split () method

Definition and usage

The split () method is used to decompose a string into an array object.

Grammar

StringObject.split (separator,howmany)

Be careful

Note: if an empty character ("") is used as a delimiter, the string will be decomposed into an array of each contained character.

Example

In this example, we will decompose a string in two different ways:

Varstr= "Howareyoudoingtoday?" [xss_clean] (str.split (") +") [xss_clean] (str.split (") +") [xss_clean] (str.split (", 3))

The output is as follows:

How,are,you,doing,today? H,o,w,a,r,e,y,o,u,d,o,i,n,g,t,o,d,a,y,? This is the end of How,are,you 's introduction to "how JavaScript uses the split () method". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Tags: Methods characters strings knowledge differences arrays industries utility content examples practicality reality objects articles more cases knowledge points empty characters symbols articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Huawei Microsoft Docker Apple