[thelist] Using for loops with a twist
Matt Warden
mwarden at gmail.com
Mon Apr 2 17:58:34 CDT 2007
On 4/2/07, Christian Heilmann <codepo8 at gmail.com> wrote:
> var arr = [1,2,0,4,5];
> for(var i=0;arr[i];i++){
> alert(arr[i]);
> }
>
> However, as 0 is falsy, you need to check properly:
>
> var arr = [1,2,0,4,5];
> for(var i=0;arr[i]!==undefined;i++){
> alert(arr[i]);
> }
What happens to this if you do:
delete arr[1];
?
--
Matt Warden
Cleveland, OH, USA
http://mattwarden.com
This email proudly and graciously contributes to entropy.
More information about the thelist
mailing list