Javascript how to split string characters into variables -
i trying split string's characters variables this:
<script> var string = "hello"; //after splitting: var stringat1 = "h"; var stringat2 = "e"; var stringat3 = "l"; var stringat4 = "l"; var stringat5 = "o"; </script>
could give example of how can done?
string.prototype.split() function can used requirement.
the
split()
method splitsstring
object array of strings separating string substrings.
usage
var string = "hello"; var arr = string.split(''); var stringat1 = arr[0]; alert(stringat1)
Comments
Post a Comment