473,322 Members | 1,522 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

prototype.js functions in an array?

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

Oct 22 '06 #1
5 1303
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/
Oct 22 '06 #2

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.

Oct 23 '06 #3

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

Oct 23 '06 #4
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/
Oct 23 '06 #5
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

Oct 23 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: petermichaux | last post by:
Hi, I've been reading the recent posts and older archives of comp.lang.javascript and am surprised by the sentiments expressed about the prototype.js library for a few reasons: 1) The library...
17
by: Chaprasi | last post by:
Hi I need help with prototype while doing ajax calls. So this is my JS which does a ajax calls var ajax1 = new Ajax.Request ( url, { method: 'get', parameters: params, onComplete:...
1
by: Peter Michaux | last post by:
Hi, What happens if you do this? function Person() {} Person.prototype = 7; var ted = new Person(); Also what happens if you set Person.prototype to an array or function?
83
by: liketofindoutwhy | last post by:
I am learning more and more Prototype and Script.aculo.us and got the Bungee book... and wonder if I should get some books on jQuery (jQuery in Action, and Learning jQuery) and start learning about...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.