How to use the Split function in JavaScript

Source: Internet
Author: User
Tags join split

This article is mainly on the use of JS Split function of the introduction, the need for friends can come to the reference, I hope to help you

Split split is the opposite of join, which is used to divide a string into an array of strings.   Stringobject.split (A,B) This is its syntax. A is the necessary decision from a this division. B is not a must, optional. This parameter specifies the maximum length of the array to return. If this argument is set, the returned substring will not be more than the array specified by this parameter.   If this argument is not set, the entire string is split, regardless of its length. Note that the returned array does not include a itself; hint and comment note: If an empty string ("") is used as a, then each character in the Stringobject is split.   Note: The actions performed by String.Split () are the opposite of those performed by Array.join. Example var str= "Hello world!"; document.write (Str.split ("") + "<br/>"); document.write (Str.split ("") + "<br/>");   document.write (Str.split ("", 3) + "<br/>"); Return to H,e,l,l,o, w,o,r,l,d,! hello,world! H,e,l
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.