I wanted to split a string into individual characters for output, and I thought about using string.split("") to convert my string into an array, but I found that it wasn't necessary. Look at this:
<script type = "text/javascript" language = "Javascript">
var vx = "FGHIFKL"
for (var i = 0; var i<vx.length; i++)
{
document.write(vx[i]); // Outputs FGHIFKL
}
</script>
It seems you can access strings as if they were arrays by using vx[0] without explicitly using str.split. Because vx[0] = F, vx[1] = G, etc. Is this syntax generally allowed, or even recommended for use in browsers? And how come this even works? I didn't know you could do something like this until today. Thanks in advance!