27.9.2011 21:23, Dr J R Stockton wrote:
>> You could have made this discussion much shorter by telling what you
>> actually tested and why you think it failed.
>
> Only if I could remember what it actually was.
I guess that's your way of apologizing the confusion you've caused.
> Veterans might have suspected it to have initially been the first form
> in <http://www.merlyn.demon.co.uk/js-props.htm>, for which the code is
> in <http://www.merlyn.demon.co.uk/inc-prop.js>.
Are "veterans" supposed to be mind-readers and make sense of a
pointlessly messy form?
> The next thing is that entering the strings Math & Date give,
> with the lower radio-button selected, entries for sections 2 to 6; but
> with new Date() sections 2 to 6 do not appear with either button.
This looks like a rather indirect way of saying that you called
Object.getOwnPropertyNames() with an argument that is a Date instance
and was surprised at seeing that it returned an empty array.
The issue does not seem to have anything to do with eval(). You can test
it directly by using e.g.
alert(Object.getOwnPropertyNames(new Date()).length);
Which own properties did you expect a Date instance to have? ECMA-262
does not mention any. It says:
"15.9.6 Properties of Date Instances
Date instances inherit properties from the Date prototype object and
their [[Class]] internal property value is "Date". Date instances also
have a [[PrimitiveValue]] internal property."
Internal properties are not returned by Object.getOwnPropertyNames().
Thus, eval('new Date()') returns a Date instance. Your method of testing
whether it does is just faulty.
--
Yucca,
http://www.cs.tut.fi/~jkorpela/