N
nick
Quick question...
It's my understanding that accessing a string as an array of
characters is a non-standard feature, not supported everywhere. I have
some code where I want to access a string as an array of characters.
When I call .split("") on a string (the argument is an empty string),
an array-like object is returned with each element being one character
of the original string. How widely supported is this behavior? Should
the example code below work in the major desktop and mobile browsers?
example code:
function something (str) {
if (!' '[0]) str = str.split('');
for (var i=0; i<str.length; i++) {
var c = str;
// do something with c...
}
}
TIA for advice.
-- Nick
It's my understanding that accessing a string as an array of
characters is a non-standard feature, not supported everywhere. I have
some code where I want to access a string as an array of characters.
When I call .split("") on a string (the argument is an empty string),
an array-like object is returned with each element being one character
of the original string. How widely supported is this behavior? Should
the example code below work in the major desktop and mobile browsers?
example code:
function something (str) {
if (!' '[0]) str = str.split('');
for (var i=0; i<str.length; i++) {
var c = str;
// do something with c...
}
}
TIA for advice.
-- Nick