Re: Has square bracket syntax always been supported ?

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Randy Webb (HikksNotAtHome_at_aol.com)
Date: 08/24/04


Date: Tue, 24 Aug 2004 08:50:42 -0400

Saint Jude wrote:
> Just a quickie.
>
> I wondered whether Javascript has always supported square bracket syntax for
> object properties.
> (some things lead me to believe it must have).

Yes.

> This is just a matter of interest.
> I'm trying to figure out the reason for the early (and still lingering)
> proliferation of eval("objectName.propertyName=" +valueString) statements
> in commonly available scripts.

Lack of better sense.

> I'm thinking
>
> 1. [] wasn't available, or

It was available.

> 2. These scripts were created by experienced programmers
> (exposed to Bash etc, perhaps)
> recently having learned Javascript, and unaware of its flexibility.

That is highly doubtful. Most people learning script learn it by
practicing, viewing other scripts, and reading books. All 3 sources,
unfortunately, use eval when its not needed.

eval is also propagated by the non-informed that write articles about
Javascript and think its "neat" to have a single way to do a lot of things.

About a year ago (I don't remember the exact time frame), I got an email
from a writer for one of the online computing magazines that wanted to
do an article on how great eval was <shudder>. He had searched the
archives and found a post of mine where I was trying to come up with a
non-eval way to convert a fraction to a decimal, other than splitting it
on the / and dividing.
Long URL:
<URL:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=20030818000514.00545.00000076%40mb-m02.aol.com&rnum=1&prev=/groups%3Fq%3Dhikksnotathome%2520eval%26hl%3Den%26lr%3D%26ie%3DUTF-8%26sa%3DN%26tab%3Dwg
>
Short URL:
http://tinyurl.com/6ny5l

What the "writer" did was searched the archives, ignored all the posts
against eval, and wanted to use some of the test pages I made comparing
eval to other methods, as an argument *for* eval. I wrote back
explaining that all of my test pages were free for use, but that I did
*not* want my name mentioned as supporting eval in those contexts. I
also asked for a URL to the article when it was published, but have not
recieved one to date.

And the result, inevitably, will be that some new scripter will read
that article, see how "neat" eval is, and then over use it and keep the
cycle going.

-- 
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq


Relevant Pages

  • Re: Does Macintosh read uppercase?
    ... through any browser. ... "Jim Carlock" wrote: ... > Javascript is supposed to be case-sensitive on all platforms, ... >>>> Does Macintosh read upper and lower case scripts? ...
    (microsoft.public.frontpage.programming)
  • Re: Cant refer to innerHTML contents
    ... Since this question (returning javascript via an xmlhttprequest) pops up for everybody who starts with AJAX sooner or later, maybe we should suggest to place this code into the FAQ? ... The only thing that, I believe, needs to be added to it for iCab and IE5.2 is a test to stay out of the function at all since they both execute scripts inserted via innerHTML. ... I think IE5.2 on a mac has gone the way of NN4.xx where it is a dead browser. ...
    (comp.lang.javascript)
  • Re: why add script-tag in header section ?
    ... javascript at the bottom. ... scripts to execute as soon as possible. ... anything to do with Google or Yahoo 8though some of their employees ... may be spouting about such generalizations in blogs) or "modern web ...
    (comp.lang.javascript)
  • Re: Does Macintosh read uppercase?
    ... I was able to successfully navigate to the third form ... >>> Macs seem to be reading the fields ok and most web Bots, ... >>> have to rename the fields and their references in the javascript to all ... >>>>> Does Macintosh read upper and lower case scripts? ...
    (microsoft.public.frontpage.programming)
  • Re: Yahoo - Move Scripts to the Bottom
    ... progressive rendering, and how moving them to the document HEAD ... move scripts from the top to as low in the page as possible. ... I'm thinking about a build system for JavaScript now. ... just makes more sense to bind the behavior in the behavior layer. ...
    (comp.lang.javascript)