String split Syntax:
string.split(separator, limit)
Here separator is a character by which we want to separate string. and limit is to give up to how many number split the string.
Sample to split string [JavaScript]
<script type="text/javascript">
function splitString()
{
var str="Split Javascript String";
document.write(str.split(" "));
}
</script>
//Output //Split, Javascript, String
In above example of string split, we give space(“ ”) character to split the string with. so it splits the string with “ “ and returns array with substrings.
0 Comments :
Post a Comment