Hi I am having string called 'santhosh'. I wish to split this text as 's,a,n,t,h,o,s,h' using javascript. Is it possible? And want to save it in an array.
And I wish to check whether the splitted character is string or Numeric is it possible?
You can use an empty string as the separator argument of the split method:
var array = "santhosh".split('');
// ["s", "a", "n", "t", "h", "o", "s", "h"]
/^\d$/.test(x) where x is a variable that contains the character you want to test.<script type="text/javascript">
var myString = "Hello";
var mySplitResult = myString.split('');
document.write("The first element is " + mySplitResult[0]);
document.write("<br /> The second element is " + mySplitResult[1]);
document.write("<br /> The third forth is " + mySplitResult[2]);
document.write("<br /> The fourth element is " + mySplitResult[3]);
document.write("<br /> The fifth element is " + mySplitResult[4]);
</script>