Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > prototype.js functions in an array?

Reply
Thread Tools

prototype.js functions in an array?

 
 
Emanuele D'Arrigo
Guest
Posts: n/a
 
      10-22-2006
Hi everybody,

if you have a look to this page

http://www.manu3d.com/jsTests/test.html

you'll find a red rectangle. If you click on the rectangle
the content of an "allegedly" empty array is printed out.
As you will see, it isn't exactly empty.

http://www.manu3d.com/jsTests/test.js

holds the js code. It seems to me that this problem
is related to prototype.js as the array shows as
correctly empty if that file isn't sourced.
But can anybody explain me why is this happening?

Thank you.

Manu

 
Reply With Quote
 
 
 
 
Randy Webb
Guest
Posts: n/a
 
      10-22-2006
Emanuele D'Arrigo said the following on 10/22/2006 6:37 PM:
> Hi everybody,
>
> if you have a look to this page
>
> http://www.manu3d.com/jsTests/test.html
>
> you'll find a red rectangle. If you click on the rectangle
> the content of an "allegedly" empty array is printed out.
> As you will see, it isn't exactly empty.
>
> http://www.manu3d.com/jsTests/test.js
>
> holds the js code. It seems to me that this problem
> is related to prototype.js as the array shows as
> correctly empty if that file isn't sourced.
> But can anybody explain me why is this happening?


Because prototype extends the Array object (often un-necessarily) and
you are seeing the consequences of that. Another reason why prototype.js
is frowned upon in this group.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
 
Reply With Quote
 
 
 
 
Peter Michaux
Guest
Posts: n/a
 
      10-23-2006

Randy Webb wrote:
> Emanuele D'Arrigo said the following on 10/22/2006 6:37 PM:
> > Hi everybody,
> >
> > if you have a look to this page
> >
> > http://www.manu3d.com/jsTests/test.html
> >
> > you'll find a red rectangle. If you click on the rectangle
> > the content of an "allegedly" empty array is printed out.
> > As you will see, it isn't exactly empty.
> >
> > http://www.manu3d.com/jsTests/test.js
> >
> > holds the js code. It seems to me that this problem
> > is related to prototype.js as the array shows as
> > correctly empty if that file isn't sourced.
> > But can anybody explain me why is this happening?

>
> Because prototype extends the Array object (often un-necessarily) and
> you are seeing the consequences of that. Another reason why prototype.js
> is frowned upon in this group.


It looks like the two newest versions of Prototype don't extend Object
prototype anymore. However it doesn't look like there are any plans to
stop extending the Array prototype.

 
Reply With Quote
 
RobG
Guest
Posts: n/a
 
      10-23-2006

Peter Michaux wrote:
[...]
> It looks like the two newest versions of Prototype don't extend Object
> prototype anymore. However it doesn't look like there are any plans to
> stop extending the Array prototype.


Have they fixed the case where $() returns named elements instead of
id'd ones in IE?

e.g. given valid HTML:

<div>
<input name="foo" value="foo input">
</div>
<div id="foo">foo div<br>
<button onclick="alert($('foo').tagName);">Call $('foo')</button>
</div>

What should the alert show: the div, the input, both or an error?


--
Rob

 
Reply With Quote
 
Randy Webb
Guest
Posts: n/a
 
      10-23-2006
Peter Michaux said the following on 10/22/2006 10:34 PM:
> Randy Webb wrote:


<snip>

>> Because prototype extends the Array object (often un-necessarily) and
>> you are seeing the consequences of that. Another reason why prototype.js
>> is frowned upon in this group.

>
> It looks like the two newest versions of Prototype don't extend Object
> prototype anymore. However it doesn't look like there are any plans to
> stop extending the Array prototype.


Did you notice that I said nothing about Object's though? <g>

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
 
Reply With Quote
 
Emanuele D'Arrigo
Guest
Posts: n/a
 
      10-23-2006
Randy Webb wrote:
> Because prototype extends the Array object (often un-necessarily) and
> you are seeing the consequences of that. Another reason why prototype.js
> is frowned upon in this group.


Thanks for the confirmation Randy, and everybody else who answered.

Manu

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shared functions vs Non-Shared Functions tshad ASP .Net 11 05-27-2005 05:53 PM
Passing member functions to C functions? Steven T. Hatton C++ 7 10-07-2004 02:12 AM
please help me in distinguish redefining functions, overloading functions and overriding functions. Xiangliang Meng C++ 1 06-21-2004 03:11 AM
Help! Passing Templates functions to template functions ILLOGIC C++ 1 06-01-2004 10:51 PM
Exportable class functions as stand alone functions to .DLL or .SO Timothy Wong C++ 3 05-20-2004 01:44 PM



Advertisments