Prototype.js does not set objects's constructor property properly

N

navneet.krg

create a class myClass using prototype.js's Class.create()
then create an object foo of that myClass
then "object.constructor" will return
"function Object() { [native code for Object.Object, arity=1] }"

should be myClass

does prototype.js does not set the constructor property properly

if i create the class using
function myClass(){};
foo = new myClass()
foo.constructor
will give
function myClass() {
}
 
R

RobG

create a class myClass using prototype.js's Class.create()
then create an object foo of that myClass
[...]

Questions specifically related to features or usage of particular
libraries are off-topic here, you should try a Prototype.js news
group, e.g.:

<URL: http://groups.google.com.au/group/rubyonrails-spinoffs?hl=en&lnk=li
<FAQENTRY>

Suggested new 2nd paragraph for FAQ #2.2 (updaated[1]):

If your question relates to a particular javascript library, or
conflicts between libraries, you should ask in a news group or forum
that supports the library. The clj news group will consider questions
realted to javascript within a library if no suitable answer is
provided on the library-specific forum. Make sure you include a link
to where you asked the question, or information on the responses you
received.

</FAQENTRY>

1. <URL:
http://groups.google.com.au/group/c...l=en&lnk=gst&q=FAQENTRY+Robg#d4ca21cc1e264d8a
 
J

John G Harris

On Wed, 5 Dec 2007 at 01:39:37, in comp.lang.javascript,
create a class myClass using prototype.js's Class.create()
then create an object foo of that myClass
then "object.constructor" will return
"function Object() { [native code for Object.Object, arity=1] }"

should be myClass

The ECMAScript standard does not require every object to have or inherit
a 'constructor' property. Don't be surprised if you get an unexpected
result. In this case it looks as though the prototype chain was created
by doing new Object(); , and not altered later on.

does prototype.js does not set the constructor property properly

if i create the class using
function myClass(){};
foo = new myClass()
foo.constructor
will give
function myClass() {
}

You've forgotten to put quotes round the answer : it's the result of
calling toString on a function object.

John
 
T

Thomas 'PointedEars' Lahn

RobG said:
create a class myClass using prototype.js's Class.create()
then create an object foo of that myClass
[...]

Questions specifically related to features or usage of particular
libraries are off-topic here, you should try a Prototype.js news
group, e.g.:

<URL: http://groups.google.com.au/group/rubyonrails-spinoffs?hl=en&lnk=li

I seriously doubt this is a link to a *newsgroup*.
<FAQENTRY>

Suggested new 2nd paragraph for FAQ #2.2 (updaated[1]):

If your question relates to a particular javascript library, or
conflicts between libraries, you should ask in a news group or forum
that supports the library.

NAK. That should be reworded so that the potential disadvantage of using
the particular library can be pointed out here.
The clj news group will consider questions
realted to javascript within a library if no suitable answer is
provided on the library-specific forum.
Make sure you include a link to where you asked the question, or
information on the responses you received.

NAK. I am not going to search the Web or login to a Web forum to determine
whether or not the posting is to consider. Furthermore, it is not the
newsgroup that considers it, but the subscribers of the newsgroup. And it
should be reworded ("might") so that these people are not said to be
compelled to reply.


PointedEars
 

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,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top