Re: Dynamic variable names
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: Dynamic variable names

From: Alberto <vallini@gmail.com>
Date: Thu Nov 17 2005 - 00:21:33 CET

QUOTE
>> Yet if you'd loop it as an array
>> for(var i=0; i<a.length;i++){alert((typeof i)+' '+(typeof a[i]))}
>> that will rerturn NUMBER NUMBER

> That doesn't prove anything, i is declared as a number and
> nothing is done to change its type.

<snip>
A more meaningful test would be using - for(prop in obj) - at then the
type of the value of prop is not externally defined. If you do:-

var z = [1,2,3,4];
for(var prop in z){
    alert((typeof prop));
}
- you get 'string' reported 4 times
UNQUOTE

That's what I myself did Richard

QUOTING MYSELF
Evidence of this:
var a=[1,2,3];
for(var i in a){alert(typeof i)}

aLl those alerts shall return STRING, because you loop it as an object.

UNQUOTING MYSELF

Note I do not put you in the same pack with this Rob :-) I can tell
when someone is making a CONSTRUCTIVE contribution and has just
overlooked a part of a post - though it is not too reassuring a trend
where the parts you already stated, are stated again but now as a
better example ahahahah

However, goodbye. I am fed up of places where one says a thing, and he
is corrected by robs because he said it right, yet with his own words.
What a misery these places are.
Received on Mon Nov 21 03:31:53 2005