Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Indexing

1 view
Skip to first unread message

Graham

unread,
Jul 2, 2009, 10:12:31 AM7/2/09
to
I am a newbie to javascript . I am fine using the concept of indexing if I
already know the index of some element but I am struggling when it comes to
finding the index of an element. Here is an example: say I have an unordered
list of n rows and I set their mouseover event what code do I need in my
event handler function to return the index number of the row the mouse
pointer is over.

thanks Graham.

Thomas 'PointedEars' Lahn

unread,
Jul 2, 2009, 11:02:01 AM7/2/09
to

(There is no "javascript". You don't set the mouseover event;
you add a listener for it [that is DOM scripting, not core JS].)

It is possible, but rather inefficient (you cannot reasonably use
a host object [like a table row object] as a key in a map
[a property name in a special object]).

What do you need the index of the row for? You have a reference
to the object causing the event with `this' and can start from there.

That said, are you sure CSS :hover won't suffice?


PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>

Peter Michaux

unread,
Jul 2, 2009, 11:36:46 AM7/2/09
to
On Jul 2, 8:02 am, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:

> Graham wrote:
> > I am a newbie to javascript .

The group FAQ is a worthwhile read:

http://www.jibbering.com/faq/

> I am fine using the concept of indexing if
> > I already know the index of some element but I am struggling when it
> > comes to finding the index of an element. Here is an example: say I have
> > an unordered list of n rows  and I set their mouseover event what code do
> > I need in my event handler function to return the index number of the row
> > the mouse pointer is over.
>
> (There is no "javascript".

Unfortunately there is "javascript" in the group FAQ. <FAQENTRY>

Peter

John G Harris

unread,
Jul 2, 2009, 3:31:56 PM7/2/09
to
On Thu, 2 Jul 2009 at 08:36:46, in comp.lang.javascript, Peter Michaux
wrote:

>On Jul 2, 8:02�am, Thomas 'PointedEars' Lahn <PointedE...@web.de>
>wrote:

<snip>


>> (There is no "javascript".
>
>Unfortunately there is "javascript" in the group FAQ. <FAQENTRY>

There's nothing wrong with "javascript" unless you're referring to a
particular trade-marked product.

John
--
John Harris

David Mark

unread,
Jul 3, 2009, 2:37:08 AM7/3/09
to

I don't follow. 1.1 is:

Which newsgroups deal with javascript?

Personally, I think it should be capitalized, but I also think too
much time is wasted on this debate. As long as the FAQ doesn't call
it "JavaScript(tm)" or (God forbid) "implementations of ECMAScript", I
don't care.

Graham

unread,
Jul 3, 2009, 4:43:44 AM7/3/09
to

"Thomas 'PointedEars' Lahn" <Point...@web.de> wrote in message
news:4A4CCBE9...@PointedEars.de...

> Graham wrote:
>> I am a newbie to javascript . I am fine using the concept of indexing if
>> I already know the index of some element but I am struggling when it
>> comes to finding the index of an element. Here is an example: say I have
>> an unordered list of n rows and I set their mouseover event what code do
>> I need in my event handler function to return the index number of the row
>> the mouse pointer is over.
>
> (There is no "javascript". You don't set the mouseover event;
> you add a listener for it [that is DOM scripting, not core JS].)
>
> It is possible, but rather inefficient (you cannot reasonably use
> a host object [like a table row object] as a key in a map
> [a property name in a special object]).
>
> What do you need the index of the row for? You have a reference
> to the object causing the event with `this' and can start from there.
>
> That said, are you sure CSS :hover won't suffice?

My reason for using it is purely as a learning exercise. I have come to
javascript from a highly array orientated language and was experimenting
with the array capabilities of javascript. My test problem was the photo
gallery. I have a series of thumbnail images down each side of the page and
as the mouse pointer enters each it is displayed enlarged in the centre of
the page. The indexing was designed to identify the image and select its src
and caption from two arrays.

I have now found a workable method as the onmouseover event can be specified
with a parameter which is persistant and can be used in the event handler to
give me the index number I require. Here are a few code snippets to
demonstrate what I have come up with so far:

<li><img src="images/img08/nl1.jpg" onmouseover="mouseOver(1)"></li>
<li><img src="images/img08/nl2.jpg" onmouseover="mouseOver(2)"></li>
<li><img src="images/img08/nl3.jpg" onmouseover="mouseOver(3)"></li>

function mouseOver(n)
{
document.getElementById("image").src=(images[n]);
document.getElementById("caption").innerHTML=(captions[n]);
}

<div id="imgcap"><img id="image" src=(images[0])><span
id="caption">(captions[0])</span></div>

var images=new Array();var captions=new Array();
images[0]="ctc.jpg";captions[0]="Default image caption"
images[1]="images/img08/nl1.jpg";captions[1]="Image 1 caption."
images[2]="images/img08/nl2.jpg";captions[2]="Image 2 caption."
images[3]="images/img08/nl3.jpg";captions[3]="Image 3 caption."

My next move is to have the script populate the list tags on loading and
then to simply store each gallery as a javascript file just containing the
variables above. It is then a very simple matter to write a galley
maintenance application in my usual language which would simply generate the
required javascript files.

I would welcome any comments on the above solution particularly if the
approach has any obvious performance penalties or other pitfalls. It works
fine with Firefox and IE7 on my machine.

Graham.


nickfitz

unread,
Jul 3, 2009, 6:01:14 AM7/3/09
to
On Jul 3, 9:43 am, "Graham" <h2gt2g42-micenewgro...@yahoo.co.uk>
wrote:

> My reason for using it is purely as a learning exercise. I have come to
> javascript from a highly array orientated language and was experimenting
> with the array capabilities of javascript.

You aren't using the array capabilities of JavaScript in the example
you give; you are dealing with nodes in the Document Object Model
(DOM), which is a tree (or an acyclic directed graph to be precise).

It's very important to understand the distinction between that which
is provided by the language, JavaScript, and that which is provided by
the environment in which the language is hosted. There is more
information with some useful links in the group FAQ: <http://
www.jibbering.com/faq/#tips>

Regards,

Nick.

Graham

unread,
Jul 3, 2009, 6:09:31 AM7/3/09
to

"nickfitz" <nick...@googlemail.com> wrote in message
news:efe807e9-ae53-4a9b...@37g2000yqp.googlegroups.com...
On Jul 3, 9:43am, "Graham" <h2gt2g42-micenewgro...@yahoo.co.uk>

Regards,

Nick.

Thanks Nick for pointing out the distinction between the language and the
environment in this case. An earlier comment now makes sense. I am familiar
with object models in other contexts so hopefully it will not take too long
to master this one.

Graham.

Thomas 'PointedEars' Lahn

unread,
Jul 3, 2009, 6:53:20 AM7/3/09
to
Graham wrote:

> "Thomas 'PointedEars' Lahn" wrote:
>> Graham wrote:
>>> I am a newbie to javascript . I am fine using the concept of indexing if
>>> I already know the index of some element but I am struggling when it
>>> comes to finding the index of an element. Here is an example: say I have
>>> an unordered list of n rows and I set their mouseover event what code do
>>> I need in my event handler function to return the index number of the row
>>> the mouse pointer is over.
>> (There is no "javascript". You don't set the mouseover event;
>> you add a listener for it [that is DOM scripting, not core JS].)
>>
>> It is possible, but rather inefficient (you cannot reasonably use
>> a host object [like a table row object] as a key in a map
>> [a property name in a special object]).
>>
>> What do you need the index of the row for? You have a reference
>> to the object causing the event with `this' and can start from there.
>>
>> That said, are you sure CSS :hover won't suffice?
>
> My reason for using it is purely as a learning exercise. I have come to
> javascript from a highly array orientated language and was experimenting
> with the array capabilities of javascript.

Now you have learned something. In highly dynamic object-oriented languages
and (DOM) APIs like these, largely forget about indexes and work with object
references (like `this') and property names instead.

> My test problem was the photo gallery. I have a series of thumbnail images
> down each side of the page and as the mouse pointer enters each it is
> displayed enlarged in the centre of the page. The indexing was designed
> to identify the image and select its src and caption from two arrays.
>
> I have now found a workable method as the onmouseover event can be specified
> with a parameter which is persistant and can be used in the event handler to
> give me the index number I require. Here are a few code snippets to
> demonstrate what I have come up with so far:
>
> <li><img src="images/img08/nl1.jpg" onmouseover="mouseOver(1)"></li>
> <li><img src="images/img08/nl2.jpg" onmouseover="mouseOver(2)"></li>
> <li><img src="images/img08/nl3.jpg" onmouseover="mouseOver(3)"></li>

And if you decide to change the order of the images or add more, you
re-number all of your calls (provided this is not generated dynamically)?

> function mouseOver(n)
> {
> document.getElementById("image").src=(images[n]);

(Indentation of statement blocks would be appropriate, see below.)

You only need to get the left-hand side reference once. Store it somewhere
(a global variable or, better, another globally available property), and use
that instead.

> document.getElementById("caption").innerHTML=(captions[n]);

Avoid the proprietary "innerHTML" property for it is error-prone; favor
standards-compliant DOM scripting (attribute properties, firstChild,
lastChild, nodeValue, textContent; removeChild(), createElement(),
createTextNode(), appendChild(), insertNode() if necessary).

And you really don't need to paranthesize the right-hand side.

> }
>
> <div id="imgcap"><img id="image" src=(images[0])><span
> id="caption">(captions[0])</span></div>

That is not Valid HTML. Attribute values that contain such non-word
characters must be quoted, and the IMG element requires an `alt' attribute:

<http://validator.w3.org/>

> var images=new Array();var captions=new Array();

Good that you declare your identifiers as variables. I don't see that often
from newbies. You want to reduce *global* variables to a minimum, though.

> images[0]="ctc.jpg";captions[0]="Default image caption"
> images[1]="images/img08/nl1.jpg";captions[1]="Image 1 caption."
> images[2]="images/img08/nl2.jpg";captions[2]="Image 2 caption."
> images[3]="images/img08/nl3.jpg";captions[3]="Image 3 caption."

No need for explicit tedious indexing:

var images = new Array("ctc.jpg", "images/img08/nl1.jpg",
"images/img08/nl2.jpg", "images/img08/nl3.jpg");

or

var images = ["ctc.jpg", "images/img08/nl1.jpg", "images/img08/nl2.jpg",
"images/img08/nl3.jpg"];

No need for two arrays, risking inconsistencies; you can make arrays of objects:

var images = [
{url: "ctc.jpg", caption: "Default image caption"},
{url: "images/img08/nl1.jpg", caption: "Image 1 caption."},
{url: "images/img08/nl2.jpg", caption: "Image 2 caption."},
{url: "images/img08/nl3.jpg", caption: "Image 3 caption."}
];

If you don't like duplication of property names in code, create your own
object type and let its constructor take care of it:

function MyImage(sUrl, sCaption)
{
this.url = sURL || "";
this.caption = sCaption || "";
}

var images = [
new MyImage("ctc.jpg", "Default image caption"),
new MyImage("images/img08/nl1.jpg", "Image 1 caption."),
new MyImage("images/img08/nl2.jpg", "Image 2 caption."),
new MyImage("images/img08/nl3.jpg", "Image 3 caption.")
];

With much and varying initialization data, though, the following pattern can
turn out to be better maintainable:

function MyImage(oData)
{
this.url = oData.url || "";
this.alt = oData.alt || "";
this.caption = oData.caption || "";
this.copyright = oData.copyright || "";
}

var images = [
new MyImage({
url: "ctc.jpg",
caption: "Default image caption",
copyright: "(C) 2009 Graham X."
}),

new MyImage({
url: "images/img08/nl1.jpg",
caption: "Image 1 caption."
}),

new MyImage({
url: "images/img08/nl2.jpg"
}),

new MyImage({
alt: "Not uploaded yet"
})
];

(And you can combine the two, of course.)

You can even use iteration over those enumerable properties if you are
careful about the code that you use elsewhere:

function MyImage(oData)
{
for (var p in oData)
{
this[p] = oData[p] || "";
}
}

But your best move here is to have an augmented Object object that has
properties with the same name as your images. In a nutshell (without
required feature tests etc.):

var myImages = {
foo: {
url: "images/img08/nl1.jpg",
alt: "foobar"
}
];

function hoverMe(oImg, bHover)
{
if (bHover)
{
var target = document.images["imgcap"];
var data = myImages[oImg.name];
target.src = data.url;
target.alt = data.alt;
/* ... */
}
else
{
/* ... */
}
}

<img src="" name="foo" alt=""
onmouseover="hoverMe(this, true)"
onmouseout="hoverMe(this, false)">

<img src="" name="imgcap" alt="">

Basically that is what hoverMe does:

<http://PointedEars.de/scripts/test/dom/hoverMe>

> My next move is to have the script populate the list tags on loading

"List tags"?

You should reconsider. First learn about the basics of the languages, then
about the APIs that can be used with them. Available evidence suggests
going down a different path is invariably a recipe for disaster (cf. jQuery
and other advertised "library" junk).


HTH

PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee

Thomas 'PointedEars' Lahn

unread,
Jul 3, 2009, 6:57:56 AM7/3/09
to
Thomas 'PointedEars' Lahn wrote:
> var myImages = {
> foo: {
> url: "images/img08/nl1.jpg",
> alt: "foobar"
> }
> ];

JFTR: Must be

};

of course.

Graham

unread,
Jul 3, 2009, 7:47:19 AM7/3/09
to

"Thomas 'PointedEars' Lahn" <Point...@web.de> wrote in message
news:4A4DE3...@PointedEars.de...

Thomas/Pointed Ears (whichever you prefer).

Thanks very much for your detailed response. I clearly have a lot to learn
and I will study your response carefully. With regard to your last comment I
see your point but I find tackling a real problem the easiest way to learn a
new language(s). I am not very good at ploughing my way through long
tutorials or text books.

Thanks again,

Graham.

Thomas 'PointedEars' Lahn

unread,
Jul 3, 2009, 10:24:54 AM7/3/09
to
Graham wrote:
> [full quote]
> [comment]

I wanted to tell you about this and more in private, but unfortunately,
something appears to be wrong with your mailbox:

| <h2gt2g42-mi...@yahoo.co.uk>: host
| mx2.mail.eu.yahoo.com[77.238.177.142] said: 554 delivery error: dd
| This user doesn't have a yahoo.co.uk account
| (h2gt2g42-mi...@yahoo.co.uk) [-101] - mta116.mail.ird.yahoo.com
| (in reply to end of DATA command)

I do hope I haven't completely wasted my time trying to help you.

<http://www.interhack.net/pubs/munging-harmful/>


PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann

Graham

unread,
Jul 3, 2009, 10:53:24 AM7/3/09
to

"Thomas 'PointedEars' Lahn" <Point...@web.de> wrote in message
news:4A4E14B6...@PointedEars.de...

> Graham wrote:
>> [full quote]
>> [comment]
>
> I wanted to tell you about this and more in private, but unfortunately,
> something appears to be wrong with your mailbox:
>
> | <h2gt2g42-mi...@yahoo.co.uk>: host
> | mx2.mail.eu.yahoo.com[77.238.177.142] said: 554 delivery error: dd
> | This user doesn't have a yahoo.co.uk account
> | (h2gt2g42-mi...@yahoo.co.uk) [-101] -
> mta116.mail.ird.yahoo.com
> | (in reply to end of DATA command)
>
> I do hope I haven't completely wasted my time trying to help you.

Certainly not. As I was new to the group and did not know what sort of
responses I might get I did not use my full newsgroup signature which
includes:

"Kill the mice to reply"

If you are a Douglas Adams fan my e-mail address might make a bit more
sense. If note simply delete the word mice from my address to respond
privately.

Thanks,
Graham.

Thomas 'PointedEars' Lahn

unread,
Jul 3, 2009, 7:51:33 PM7/3/09
to
Graham wrote:

> "Thomas 'PointedEars' Lahn" wrote:
>>> [full quote]
>>> [comment]
>> I wanted to tell you about this and more in private, but unfortunately,
>> something appears to be wrong with your mailbox:
>>
>> | <h2gt2g42-mi...@yahoo.co.uk>: host
>> | mx2.mail.eu.yahoo.com[77.238.177.142] said: 554 delivery error: dd
>> | This user doesn't have a yahoo.co.uk account
>> | (h2gt2g42-mi...@yahoo.co.uk) [-101] -
>> mta116.mail.ird.yahoo.com
>> | (in reply to end of DATA command)
>>
>> I do hope I haven't completely wasted my time trying to help you.
>
> Certainly not.

Most definitely I did :-( Maybe I should write myself a Thunderbird
extension that can check From and Reply-To headers using chkmadd(1) or an
equivalent ...

> As I was new to the group and did not know what sort of
> responses I might get I did not use my full newsgroup signature which
> includes:
>
> "Kill the mice to reply"

I was afraid you might say something like that. Since I like animals, I'll
kill your postings instead (at least those using such antisocial headers).

> If you are a Douglas Adams fan my e-mail address might make a bit more
> sense.

As a matter of fact I am.

> If note simply delete the word mice from my address to respond
> privately.

Certainly not. It's your problem now. (Does Yahoo allow or condone
such behavior? If yes, I might need to adjust my filters.)

Garrett Smith

unread,
Jul 3, 2009, 11:05:59 PM7/3/09
to

That could go right above "what is JScript".

| What is javascript?
|
| JavaScript(TM) is the language invented by Brendan Eich for Netscape.
| However, the name "javascript" is so common, that it is used to
| describe the language itself.

I cannot now log in and I have accumulated a lot of local changes to
upload. 5 entries, one HTML edit in the file that processes the XML. I'm
also trying an alternate view to help ease reading of the burgeoning FAQ.

But I need to get access again before I can upload those.

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

Graham

unread,
Jul 4, 2009, 3:56:25 AM7/4/09
to

"Thomas 'PointedEars' Lahn" <Point...@web.de> wrote in message
news:4A4E9985...@PointedEars.de...

Somewhat of an unexpected and extreme response. Have you no sense of humour.
Perhaps onmouseOut( ) {to reply;} would be more in keeping with your
sensibilities. No matter it is clearly your choice whether you want to
continue a conversation in public or in private.

For my part I had not the slightest intention to waste your time or offend
you. My disguised email address was simply to avoid being inundated with
spam.

Thanks once again for your earlier informative responses.

Cheers,

Graham.
onmouseOut( ) {to reply;}
;)

John G Harris

unread,
Jul 4, 2009, 10:40:22 AM7/4/09
to
On Fri, 3 Jul 2009 at 20:05:59, in comp.lang.javascript, Garrett Smith
wrote:
>Peter Michaux wrote:

<snip>


>> Unfortunately there is "javascript" in the group FAQ. <FAQENTRY>
>> Peter
>
>That could go right above "what is JScript".
>
>| What is javascript?
>|
>| JavaScript(TM) is the language invented by Brendan Eich for Netscape.
>| However, the name "javascript" is so common, that it is used to
>| describe the language itself.

<snip>

That seems to be the wrong way round. I'd prefer something like :

| What is javascript ?
|
| Many products use their own names for the version of the language they
| implement : JavaScript, JScript, ActionScript, etc. Some of these
| names are registered trade marks. "javascript" is used here as
| the general name for all versions of the language.

John
--
John Harris

Thomas 'PointedEars' Lahn

unread,
Jul 5, 2009, 9:32:04 AM7/5/09
to
Garrett Smith wrote:
> Peter Michaux wrote:
>> Thomas 'PointedEars' Lahn wrote:
>>> I am fine using the concept of indexing if
>>>> I already know the index of some element but I am struggling when it
>>>> comes to finding the index of an element. Here is an example: say I have
>>>> an unordered list of n rows and I set their mouseover event what code do
>>>> I need in my event handler function to return the index number of the row
>>>> the mouse pointer is over.
>>> (There is no "javascript".
>> Unfortunately there is "javascript" in the group FAQ. <FAQENTRY>

That's a problem with the FAQ.

> That could go right above "what is JScript".

But it shouldn't.

> | What is javascript?
> |
> | JavaScript(TM) is the language invented by Brendan Eich for Netscape.
> | However, the name "javascript" is so common, that it is used to
> | describe the language itself.

What utter nonsense! "JavaScript" is the name of the language, but
"javascript" is used to describe it? ISTM you don't even know what
you want to talk about here.

> I cannot now log in and I have accumulated a lot of local changes to
> upload. 5 entries, one HTML edit in the file that processes the XML. I'm
> also trying an alternate view to help ease reading of the burgeoning FAQ.
>
> But I need to get access again before I can upload those.

Haven't you still not learned to ask before making any major changes to the FAQ?


PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$8300...@news.demon.co.uk>

Garrett Smith

unread,
Jul 5, 2009, 11:11:32 AM7/5/09
to
John G Harris wrote:
> On Fri, 3 Jul 2009 at 20:05:59, in comp.lang.javascript, Garrett Smith
> wrote:
>> Peter Michaux wrote:
>
> <snip>
>>> Unfortunately there is "javascript" in the group FAQ. <FAQENTRY>
>>> Peter
>> That could go right above "what is JScript".
>>
>> | What is javascript?
>> |
>> | JavaScript(TM) is the language invented by Brendan Eich for Netscape.
>> | However, the name "javascript" is so common, that it is used to
>> | describe the language itself.
> <snip>
>
> That seems to be the wrong way round. I'd prefer something like :
>

I agree.

> | What is javascript ?
> |
> | Many products use their own names for the version of the language they
> | implement : JavaScript, JScript, ActionScript, etc. Some of these
> | names are registered trade marks. "javascript" is used here as
> | the general name for all versions of the language.
>

I've never heard ""ActionScript"" called "javascript". Everyone I know
calls it "ActionScript".

Other than that, I like it.

Dr J R Stockton

unread,
Jul 5, 2009, 11:38:16 AM7/5/09
to
In comp.lang.javascript message <h2mh5r$krn$1...@news.eternal-
september.org>, Fri, 3 Jul 2009 20:05:59, Garrett Smith
<dhtmlk...@gmail.com> posted:

>
>That could go right above "what is JScript".
>
>| What is javascript?
>|
>| JavaScript(TM) is the language invented by Brendan Eich for Netscape.
>| However, the name "javascript" is so common, that it is used to
>| describe the language itself.


A waste of space. It does not correspond to anything that real
questioners commonly want or need to be told. Apart from Sec 2.5, all
of Sec 2 can be handled by giving links to corresponding Wikipedia
articles.

--
(c) John Stockton, nr London UK. ??@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
In MS OE, choose Tools, Options, Send; select Plain Text for News and E-mail.
Don't quote more than is needed, and respond after each quoted part.

Garrett Smith

unread,
Jul 5, 2009, 3:29:55 PM7/5/09
to
Dr J R Stockton wrote:
> In comp.lang.javascript message <h2mh5r$krn$1...@news.eternal-
> september.org>, Fri, 3 Jul 2009 20:05:59, Garrett Smith
> <dhtmlk...@gmail.com> posted:
>> That could go right above "what is JScript".
>>
>> | What is javascript?
>> |
>> | JavaScript(TM) is the language invented by Brendan Eich for Netscape.
>> | However, the name "javascript" is so common, that it is used to
>> | describe the language itself.
>
>
> A waste of space. It does not correspond to anything that real
> questioners commonly want or need to be told. Apart from Sec 2.5, all
> of Sec 2 can be handled by giving links to corresponding Wikipedia
> articles.
>

I see.

The goal was to differentiate between "JavaScript" as in "Mozilla's
JavaScript" and "javascript" (lower case) to mean "ECMAScript".

I think it's worth mentioning.

The "What is Jscript" seems like a better candidate for removal because
the entry "What is ECMAScript" states:
| JScript and JavaScript� are implementations of ECMAScript.

But that could be changed to: "...are dialects of ECMAScript."

What do you think about removing "What is Jscript"?

Garrett
--
comp.lang.javascript FAQ: [where?]

Peter Michaux

unread,
Jul 5, 2009, 3:46:29 PM7/5/09
to
On Jul 3, 8:05 pm, Garrett Smith <dhtmlkitc...@gmail.com> wrote:

> I'm also trying an alternate view
> to help ease reading of the burgeoning FAQ.

I think the FAQ is quite easy to read as it is now.

The only change I could see being justified would be to break the FAQ
into separate documents in order to reduce server load (though that
may backfire.) This would also break the many existing links to the
FAQ.

Peter

Garrett Smith

unread,
Jul 5, 2009, 7:49:02 PM7/5/09
to
Garrett Smith wrote:
> Dr J R Stockton wrote:
>> In comp.lang.javascript message <h2mh5r$krn$1...@news.eternal-
>> september.org>, Fri, 3 Jul 2009 20:05:59, Garrett Smith
>> <dhtmlk...@gmail.com> posted:

[earlier rough (bad) draft]

>>
>> A waste of space. It does not correspond to anything that real
>> questioners commonly want or need to be told. Apart from Sec 2.5, all
>> of Sec 2 can be handled by giving links to corresponding Wikipedia
>> articles.
>>
>
> I see.
>
> The goal was to differentiate between "JavaScript" as in "Mozilla's
> JavaScript" and "javascript" (lower case) to mean "ECMAScript".
>
> I think it's worth mentioning.
>
> The "What is Jscript" seems like a better candidate for removal because
> the entry "What is ECMAScript" states:
> | JScript and JavaScript� are implementations of ECMAScript.
>
> But that could be changed to: "...are dialects of ECMAScript."
>
> What do you think about removing "What is Jscript"?
>

And having:-
| What is javascript?
|
| Many products use their own names for the dialect of the language they
| implement: JavaScript, JScript, etc. Some of these names are
| registered trademarks. The term "javascript", is used here as the
| general name for all dialects of the language.

?

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

Garrett Smith

unread,
Jul 5, 2009, 7:59:09 PM7/5/09
to

OR maybe add to "What is ECMAScript":-

| The term "javascript", is used as a general name for all dialects of
| ECMAScript.

or...?

Let me know. I'm going out now.

Dr J R Stockton

unread,
Jul 6, 2009, 1:04:09 PM7/6/09
to
In comp.lang.javascript message <h2qv74$2qm$1...@news.eternal-
september.org>, Sun, 5 Jul 2009 12:29:55, Garrett Smith
<dhtmlk...@gmail.com> posted:

>Dr J R Stockton wrote:
>> In comp.lang.javascript message <h2mh5r$krn$1...@news.eternal-
>> september.org>, Fri, 3 Jul 2009 20:05:59, Garrett Smith
>> <dhtmlk...@gmail.com> posted:
>>> That could go right above "what is JScript".
>>>
>>> | What is javascript?
>>> |
>>> | JavaScript(TM) is the language invented by Brendan Eich for Netscape.
>>> | However, the name "javascript" is so common, that it is used to
>>> | describe the language itself.
>> A waste of space. It does not correspond to anything that real
>> questioners commonly want or need to be told. Apart from Sec 2.5, all
>> of Sec 2 can be handled by giving links to corresponding Wikipedia
>> articles.
>>
>
>I see.
>
>The goal was to differentiate between "JavaScript" as in "Mozilla's
>JavaScript" and "javascript" (lower case) to mean "ECMAScript".
>
>I think it's worth mentioning.
>
>The "What is Jscript" seems like a better candidate for removal because
>the entry "What is ECMAScript" states:
>| JScript and JavaScript™ are implementations of ECMAScript.

>
>But that could be changed to: "...are dialects of ECMAScript."
>
>What do you think about removing "What is Jscript"?

The second sentence of 2.2 belongs in Section 1.1.

The second sentence of 2.1 can be replaced by the first sentence of 2.2;
in 2.1, "and JavaScript™" serves no useful purpose; the TM can be hung
on the previous JavaScript if required.

Section 2.2 then becomes empty.

The content of 2.6 belongs at the end of 2.1.

2.1 para 3 can be replaced by the shorter

ECMA-327 defines the Compact Profile of ECMAScript, for
resource-limited systems. <link>

Section 2.3 sentence 3 is still false, being refuted by the next one.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.


Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.

Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "> " (SonOfRFC1036)

Dr J R Stockton

unread,
Jul 6, 2009, 6:39:24 PM7/6/09
to
In comp.lang.javascript message <h2red1$i6v$1...@news.eternal-
september.org>, Sun, 5 Jul 2009 16:49:02, Garrett Smith
<dhtmlk...@gmail.com> posted:

>And having:-
>| What is javascript?
>|
>| Many products use their own names for the dialect of the language
>they
>| implement: JavaScript, JScript, etc. Some of these names are
>| registered trademarks. The term "javascript", is used here as the
>| general name for all dialects of the language.
>

A further waste of space (and ill-punctuated). If you feel a need to
write such material, it should be put on a personal web site, where it
can conveniently be ignored.

There is no need to repeat that which Wikipedia treats adequately.

The FAQ is too big : the aim should be to deduce its size, by saying
only what it is useful to say, and by saying that compactly.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.


Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.

Garrett Smith

unread,
Jul 7, 2009, 3:18:04 AM7/7/09
to
Dr J R Stockton wrote:
> In comp.lang.javascript message <h2qv74$2qm$1...@news.eternal-
> september.org>, Sun, 5 Jul 2009 12:29:55, Garrett Smith
> <dhtmlk...@gmail.com> posted:
>> Dr J R Stockton wrote:
>>> In comp.lang.javascript message <h2mh5r$krn$1...@news.eternal-
>>> september.org>, Fri, 3 Jul 2009 20:05:59, Garrett Smith
>>> <dhtmlk...@gmail.com> posted:
>>>> That could go right above "what is JScript".
>>>>
>>>> | What is javascript?
>>>> |
>>>> | JavaScript(TM) is the language invented by Brendan Eich for Netscape.
>>>> | However, the name "javascript" is so common, that it is used to
>>>> | describe the language itself.
>>> A waste of space. It does not correspond to anything that real
>>> questioners commonly want or need to be told. Apart from Sec 2.5, all
>>> of Sec 2 can be handled by giving links to corresponding Wikipedia
>>> articles.
>>>
>> I see.
>>
>> The goal was to differentiate between "JavaScript" as in "Mozilla's
>> JavaScript" and "javascript" (lower case) to mean "ECMAScript".
>>
>> I think it's worth mentioning.
>>

I still think it is worth mentioning.

>> The "What is Jscript" seems like a better candidate for removal because
>> the entry "What is ECMAScript" states:
>> | JScript and JavaScript™ are implementations of ECMAScript.
>>
>> But that could be changed to: "...are dialects of ECMAScript."

Did that.

>>
>> What do you think about removing "What is Jscript"?
>
> The second sentence of 2.2 belongs in Section 1.1.
>

Yep.

> The second sentence of 2.1 can be replaced by the first sentence of 2.2;
> in 2.1, "and JavaScript™" serves no useful purpose; the TM can be hung
> on the previous JavaScript if required.
>

Yep.

> Section 2.2 then becomes empty.
>

Yep.

> The content of 2.6 belongs at the end of 2.1.
>
> 2.1 para 3 can be replaced by the shorter
>
> ECMA-327 defines the Compact Profile of ECMAScript, for
> resource-limited systems. <link>
>

Why not inform the reader that there are features missing? That's a good
thing. They can go read it to find that |with| may be omitted, etc.

> Section 2.3 sentence 3 is still false, being refuted by the next one.
>

Yep. Jorge pointed that out a long while ago.

The whole entry needs a rewrite and I never got to that. There was some
disagreement on the DOM and I/O. Mainly, I disagree that the W3C DOM and
the window object provide a form of I/O. AISI, javascript that performs
dynamic manipulation of the content, style, etc is acting as a
"controller" for the "model". The "object model", in this case, is the
semantic DOM nodes (Elements, Text, Attributes).

http://groups.google.com/group/comp.lang.javascript/browse_thread/thread/96419eb9312c1436/1a24df013db60248#1a24df013db60248

For now, I am going to remove those two egregiously incorrect sentences
and change the first sentence's colon (incorrect) to a semicolon and the
misplaced comma in the second sentence. A rewrite can come later.

Regarding "What is ECMAScript", I added:-
| The term "javascript" is used as a common name for all dialects of
| ECMAScript.

This is important because it differentiates between JavaScript(TM) and
the common use of "javascript" everywhere (work, interviews, the FAQ,
this NG). Some may disagree with the lowercase "javascript", and to
those, this sentence explains what the FAQ means by "javascript",
without trying to justify that as being correct and proper.


If you've not been counting, the number of changed FAQ entries we've
discussed is now up to eight. When SSH access is restored, I'll upload.

Dr J R Stockton

unread,
Jul 7, 2009, 2:48:39 PM7/7/09
to
In comp.lang.javascript message <h2ut3g$q5s$1...@news.eternal-
september.org>, Tue, 7 Jul 2009 00:18:04, Garrett Smith
<dhtmlk...@gmail.com> posted:

>> 2.1 para 3 can be replaced by the shorter
>> ECMA-327 defines the Compact Profile of ECMAScript, for
>> resource-limited systems. <link>
>
>Why not inform the reader that there are features missing?

There is no need to bother about those who are not intelligent enough to
realise that a Compact Profile for resource-limited systems can be
expected to have features missing.


The unwanted </li><li> in Section 5.5 can be reused for a link to
<http://en.wikipedia.org/wiki/Random_number_generator>, which is of
interest in itself and links to related wiki pages.

Before that list, add "Math.random output quality is mediocre and
browser-dependent." That could, but probably will not, need changing
when browsers all comply with ECMA 5.

There should also be a path indicated for reproducible random and better
random :

# http://www.merlyn.demon.co.uk/js-randm.htm (with Algorithms, Shuffle,
Deal, Draw, etc.)

--
(c) John Stockton, nr London UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
<URL:http://www.merlyn.demon.co.uk/clpb-faq.txt> RAH Prins : c.l.p.b mFAQ;
<URL:ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal FAQ.

David Mark

unread,
Jul 7, 2009, 6:57:11 PM7/7/09
to
On Jul 6, 6:39 pm, Dr J R Stockton <reply0...@merlyn.demon.co.uk>
wrote:
> In comp.lang.javascript message <h2red1$i6...@news.eternal-

> september.org>, Sun, 5 Jul 2009 16:49:02, Garrett Smith
> <dhtmlkitc...@gmail.com> posted:

>
> >And having:-
> >| What is javascript?
> >|
> >| Many products use their own names for the dialect of the language
> >they
> >| implement: JavaScript, JScript, etc. Some of these names are
> >| registered trademarks. The term "javascript", is used here as the
> >| general name for all dialects of the language.
>
> A further waste of space (and ill-punctuated).

That's not a sentence, so it is also ill-punctuated. ISTM the period
should go inside the parentheses as well. What does your style guide
say about sentence fragments?

> If you feel a need to
> write such material, it should be put on a personal web site, where it
> can conveniently be ignored.

By coincidence, I feel much the same way about many of your posts.

>
> There is no need to repeat that which Wikipedia treats adequately.

Wikipedia is a crock. What is it about JS that they cover adequately?

>
> The FAQ is too big : the aim should be to deduce its size, by saying
> only what it is useful to say, and by saying that compactly.

I assume you meant to *reduce* its size. You are slipping, doc.

Message has been deleted

David Mark

unread,
Jul 7, 2009, 9:00:19 PM7/7/09
to
On Jul 7, 8:36 pm, Tim Streater <timstrea...@waitrose.com> wrote:
> In article
> <4c376042-5131-486e-a8ed-d3a78388f...@h31g2000yqd.googlegroups.com>,

>  David Mark <dmark.cins...@gmail.com> wrote:
>
>
>
> > On Jul 6, 6:39 pm, Dr J R Stockton <reply0...@merlyn.demon.co.uk>
> > wrote:
> > > In comp.lang.javascript message <h2red1$i6...@news.eternal-
> > > september.org>, Sun, 5 Jul 2009 16:49:02, Garrett Smith
> > > <dhtmlkitc...@gmail.com> posted:
>
> > > >And having:-
> > > >| What is javascript?
> > > >|
> > > >| Many products use their own names for the dialect of the language
> > > >they
> > > >| implement: JavaScript, JScript, etc. Some of these names are
> > > >| registered trademarks. The term "javascript", is used here as the
> > > >| general name for all dialects of the language.
>
> > > A further waste of space (and ill-punctuated).
>
> > That's not a sentence, so it is also ill-punctuated.
>
> Actually that doesn't follow. As it stands it's not a sentence since
> there is no verb and I can't find a subject. However I think we can
> infer the prepending of "That is".

Looks like a fragment to me. I don't see how that inference matters.

>
> > ISTM the period should go inside the parentheses as well.
>

> No, the full-stop is correctly placed at the end of the (non) sentence.
>
> Not that any of this matters a crap.

Obviously not. But the good doctor belittles others constantly about
English (even those who learned it as a second language).

It seemed ironic to me. Or perhaps he will correct me. Certainly
it's news to me that the period would go outside the parentheses.
Live and learn.

L.@canberra Trevor Lawrence

unread,
Jul 8, 2009, 3:24:00 AM7/8/09
to

--
Trevor Lawrence
Canberra
Web Site http://trevorl.mvps.org
"David Mark" <dmark....@gmail.com> wrote in message
news:afeb1802-1fa4-4f42...@s31g2000yqs.googlegroups.com...

David Mark

unread,
Jul 8, 2009, 3:35:25 AM7/8/09
to
On Jul 8, 3:24 am, "Trevor Lawrence" <Trevor L.@Canberra> wrote:

Must be a full moon tonight (in every time zone apparently.)

You seemed about to say something, Trevor? When you get around to
doing so, please don't top-post.

Thanks!

> --
> Trevor Lawrence
> Canberra
> Web Sitehttp://trevorl.mvps.org"David Mark" <dmark.cins...@gmail.com> wrote in message

L.@canberra Trevor Lawrence

unread,
Jul 8, 2009, 3:41:34 AM7/8/09
to
"David Mark" <dmark....@gmail.com> wrote in message
news:afeb1802-1fa4-4f42...@s31g2000yqs.googlegroups.com...

David,
I have not followed this thread, but as a person without Arts or Classics
training, I like to consider points of English grammar. (Non-sequitur
intended.)

In IMHO the full-stop (period for the USAians) belongs outside the
parentheses. If what is inside the parentheses is not a sentence (and in
this case it is not) then it does not need a full-stop. My phrases in
parentheses above are not sentences so I didn't add full-stops.

I don't think that it is necessary in NGs to use exact English. After all,
your post had this fragment: "Or perhaps he will correct me.". This breaks
the rule that a sentence must not commence with a conjunction. I have been
told off for doing this myself. But surely it can be ignored for the sake of
brevity. (I trust that you noticed my irony in that my last sentence
commenced with a conjunction.)

BTW,
My last sentence above was in parentheses and has a full-stop, because it is
a complete sentence.

Enjoy the discussion

David Mark

unread,
Jul 8, 2009, 4:10:19 AM7/8/09
to
On Jul 8, 3:41 am, "Trevor Lawrence" <Trevor L.@Canberra> wrote:
> "David Mark" <dmark.cins...@gmail.com> wrote in message

You missed the irony. And *please* learn to quote. Something is
horribly wrong with your newsreader.

> After all,
> your post had this fragment: "Or perhaps he will correct me.". > This breaks
> the rule that a sentence must not commence with a conjunction.

Yes, I use fragments in posts all the time (but I don't typically
correct others on their English).

> I have been
> told off for doing this myself. But surely it can be ignored for the sake of
> brevity. (I trust that you noticed my irony in that my last sentence
> commenced with a conjunction.)

Maybe if it were earlier.

>
> BTW,
> My last sentence above was in parentheses and has a full-stop, because it is
> a complete sentence.

I get it.

>
> Enjoy the discussion

Not particularly.

Evertjan.

unread,
Jul 8, 2009, 4:17:23 AM7/8/09
to
David Mark wrote on 08 jul 2009 in comp.lang.javascript:

> Must be a full moon tonight (in every time zone apparently.)

That would in the mean only be the case, if full moon is whithin half an
hour of noon GMT, which happens only once in every 24 full moons, or two
years.

In the mean in every single time zone, only half the zone has the full moon
at night. So there would never be an entire timezone where the full moon is
apparent "tonight". Not even in one, so not in every timezone.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

David Mark

unread,
Jul 8, 2009, 4:38:19 AM7/8/09
to
On Jul 8, 4:17 am, "Evertjan." <exjxw.hannivo...@interxnl.net> wrote:
> David Mark wrote on 08 jul 2009 in comp.lang.javascript:
>
> > Must be a full moon tonight (in every time zone apparently.)
>
> That would in the mean only be the case, if full moon is whithin half an
> hour of noon GMT, which happens only once in every 24 full moons, or two
> years.
>
> In the mean in every single time zone, only half the zone has the full moon
> at night. So there would never be an entire timezone where the full moon is
> apparent "tonight". Not even in one, so not in every timezone.
>

Yes, thanks for that. I wasn't serious. I certainly hope you aren't
either.

Evertjan.

unread,
Jul 8, 2009, 9:51:20 AM7/8/09
to
David Mark wrote on 08 jul 2009 in comp.lang.javascript:

> On Jul 8, 4:17�am, "Evertjan." <exjxw.hannivo...@interxnl.net> wrote:
>> David Mark wrote on 08 jul 2009 in comp.lang.javascript:
>>
>> > Must be a full moon tonight (in every time zone apparently.)
>>
>> That would in the mean only be the case, if full moon is whithin half
>> an hour of noon GMT, which happens only once in every 24 full moons,
>> or two years.
>>
>> In the mean in every single time zone, only half the zone has the
>> full mo
> on
>> at night. So there would never be an entire timezone where the full
>> moon
> is
>> apparent "tonight". Not even in one, so not in every timezone.
>>
>
> Yes, thanks for that. I wasn't serious. I certainly hope you aren't
> either.

I knew you ment "Blue moon".

0 new messages