Being able to split into a series of separate blocks has been supported in many programming languages, and it can be in JavaScript as well. If you have a long list of names, such as "Bobysu Santresideni" and you want each store to be named separately, you can specify the space character "" and have the split feature create a new chunk each time you see the space.
Split function: Separating
Space nature "," what we mentioned would be our separation and use it to break the string with its split function. Each time we see the partition we specify, a new element will be created, an array. The split function of the first parameter is delimited.
A simple example of a split function
Let's first close the small example, take a series of numbers and split when you see the number 5. This means that the separation for this example is 5. Notice that the Split function returns an array of our stores to Mysplitresult.
<script type= "Text/javascript" >
var myString = "123456789";
var mysplitresult = Mystring.split ("5");
document.write ("The" the "the" + mysplitresult[0]);
document.write ("<br/> The second element is" + mysplitresult[1]);
</script>
Results.
The 1234
The second element is 6789
Be sure to recognize that because we chose 5 to be our separation, this is not in line with our results. This is because the separation is from the string, the rest of the character divides the space used by the 5 occupation.
to magnify the Split function example
below, we have established a split example to illustrate how this function is different from many. We have established a string number of words through four zeros. Delimited in this example will be the space character "".
<script type= "Text/javascript"
var myString = "Zero One Two three";
var Mysplitresult = Mystring.split ("");
for (i = 0; i < mysplitresult.length i++) {
document.write ("<br/> Element" + i + "=" + mysplitre Sult[i]);
}
</script>
results.
Element 0 = Zero
Element 1 = one
element 2 = two
element 3 = three
element 4 = four