how to use split() function in javascript

How to use Split() function in javascript function splitresult(){var name = ‘Rajeev-Dhar-Dwivedi’ ;var val=name.split(“-“);alert(val[0]);alert(val[1]);alert(val[2]);} String = Rajeev-Dhar-Dwivedi

function splitresult(){
var name = ‘Rajeev-Dhar-Dwivedi’ ;

var val=name.split(“-“);


String = Rajeev-Dhar-Dwivedi

for example you have a string Rajeev-Dhar-Dwived and you want to cut string every – seprator them use split() function in javascriptsplit() function is just like to explote() function in PHP
structer :
var arrayval=string.split(“seprator”); 
var str = ‘Rajeev-Dhar-Dwivedi’ ;
var val=name.split(“-“);
val[0]; // Rajeev
val[1]; // Dhar
val[2]; // Dwivedi

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s