Dynamic variable names

M

Matt Kruse

Thomas said:
window[varname] is perfectly fine, and to discourage its use
probably just confuses some people more than helps them, IMO.
No, it does not, it sharpens the sense for the difference between
language and AOM/DOM. `window' is a reference to a non-standard host
object of the AOM and its functionality depends on the host
environment. To rely on it regarding globals is error-prone.

Unless you show a single example of a browser environment where
window[varName] doesn't work, I don't think it is error-prone at all.

There is no need to write code that considers a non-browser context when you
know for sure that the code will never be run outside a browser context.
Doing so just adds unnecessary complexity and confusion to the code, IMO.
 
D

Dr John Stockton

JRS: In article <[email protected]>, dated Tue, 15 Nov 2005
14:28:49, seen in Lee
Wanting to do such a thing seems sort of like a newbie problem.
What are you really trying to do? There must be a better way.


It's quite useful if one has many calls like
Test("SomeFunction", SomeFunction)
that one wants to simplify to
Test("SomeFunction")
/* there, eval /can/ be used to evaluate parameter + "(arguments)" */ .

I prefer Test(SomeFunction)
and get the function name by way of parameter.toString(). That's only
needed once, of course, in the code of Test.
 
A

Alberto

QUOTE
Arrays *are* objects.
UNQUOTE

We can say even more, expert of my balls.

Nothing is an object.

Objects are an abstraction to mean data structures. "OBJECTS", they do
not EVEN exist.
Study some C, expert.

QUOTE
Do not think of object properties as 'keys', they are properties.
UNQUOTE

QUOTING MYSELF
As such, it is a collection of PROPERTIES.
UNQUOTING MYSELF

I can't see how i could have said it more clearly than the way i did,
capitalizing it.
If even capitalizing a thing makes you suppose it escaped my attention,
I wonder why the hack *I* am here answering to you. You have a
perception issue.

I can't see why to say such banal thing you had to quote me LOL- I
myself used the terms keys and property as basically interchangeable.
They are not so, only in your world where you spend your time counting
how many hairs are on a butt.


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


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

how ridiculous. I said the VERY same thing. As if after 10 years of
javascript i need an idiot like you to teach me that if I initialize a
variable as a Number, that reports number. I was addressing a potential
BEGINNER, moron.
How stupid and obtuse you are. I was just trying to make a beginner see
how a few things may differ THOUGH being apparently the same thing.

You're here arguing I didn't simplye because I used other words than
yours.

Get laid, or look after ur wife more often. It was not meant to "PROVE"
anything, was just a way to show to a beginner that everyhting is a
data structure (Call it object, who cares, it's a rose by another
name).
If you would be more confident about yoruself, you won't have to show a
limp dick trying to make up for it with a flaccid post. The next time
you have to make your point, you can make it avoinding to mention
persons who were saying the very same thing that you were saying with
your own words.


QUOTE
The ECMAScript Language Specification states that all object properties

are strings.
Experimentation should not required to discover it,
UNQUOTE

what an idiot., a person who hints he could be a BEGINNER has NOT read
the ECMA specification, moron. He wants to see things explained and
proved HERE and NOW not on a manual that only you and me and a few
other idiots read.


EVERY TIME I LAND ON A GROUP I INVARIBALY FIND SOME DEFICIENT WHO
ARGUES ABOUT THE WRONG POINTS. We had a beginner here. He did NOT read
the ecma specification. He was asking for EXPLANATIONS here and now. I
am not "proving" it to you, dement, I was proving it, as you implicitly
state, to a BEGINNER. The post was not for you.
When you want to show how good you are, show it to you wife. Ganfg of
assholes, EVERYTIME one helps SOMEONE else, they have to get in with
their rebuttals based on NOTHING or on the WRONG assumptions

keys, properties. I said the same thing. Ecma specification, dement
have you everv tried to teach to a beginner? bEGINNER DON'RT EVEN KNOW
ECMA EXISTS.

I sensed it IMMEDIATLE as soon as I saw pointed ears that this group
had to be the very same collection of idiots it has always been. I am
so PISSEDD off that I can't even make a contriobution to a person who
is a beginner without seeing a completelypointless rebuttal, that I
have no scruple in calling you the names you deserve. MGet this
deleted, Sue me,. **** yourself most of all.
 
A

Alberto

QUOTE
Yet if you'd loop it as an array
for(var i=0; i<a.length;i++){alert((typeof i)+' '+(typeof a))}
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.
 
R

RobG

Alberto said:
QUOTE
Arrays *are* objects.
UNQUOTE

We can say even more, expert of my balls.

Nothing is an object.

Since this is a JavaScript group, I suppose we should accept that
objects are what the ECMAScript Language Specification says they are.


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

how ridiculous. I said the VERY same thing. As if after 10 years of
javascript i need an idiot like you to teach me that if I initialize a
variable as a Number, that reports number. I was addressing a potential
BEGINNER, moron.

Then why introduce concepts and terminology from some other language?
You have no idea whether the OP has the same understanding of those
concepts or not, nor how they might be translated into Russ'
understanding of JavaScript.

How stupid and obtuse you are. I was just trying to make a beginner see
how a few things may differ THOUGH being apparently the same thing.

You're here arguing I didn't simplye because I used other words than
yours.

They are not my words, they are from the specification.


[...]
what an idiot., a person who hints he could be a BEGINNER has NOT read
the ECMA specification, moron. He wants to see things explained and
proved HERE and NOW not on a manual that only you and me and a few
other idiots read.

When all else fails, read the manual...

EVERY TIME I LAND ON A GROUP I INVARIBALY FIND SOME DEFICIENT WHO
ARGUES ABOUT THE WRONG POINTS. We had a beginner here. He did NOT read
the ecma specification. He was asking for EXPLANATIONS here and now. I
[...]

Explanations should use terminology and concepts that reflect the
language specification - trial and error should not be used to discover
fundamental principles.

The point of quoting a specification is so that a person may look for
themselves and hopefully discover any inconsistencies that may have been
lost in translation. They might even discover other useful things while
they are reading it.

I sensed it IMMEDIATLE as soon as I saw pointed ears that this group
had to be the very same collection of idiots it has always been. I am
so PISSEDD off that I can't even make a contriobution to a person who
is a beginner without seeing a completelypointless rebuttal, that I
have no scruple in calling you the names you deserve. MGet this
deleted, Sue me,. **** yourself most of all.

Bad day?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top