From: nick on
On Apr 22, 4:40 pm, Asen Bozhilov <asen.bozhi...(a)gmail.com> wrote:
> nick wrote:
> > I guess DefaultValue and hint are internal stuff I have no control
> > over?

> Internal methods are not inherited via prototype chain. [...]

I see what you mean. I have actually tested something very similar to
the example you gave, so it makes perfect sense to me. Thanks for
helping explain it.

> > > For object referred by `obj' if call [[DefaultValue]] method with no
> > > hint, will be treat as hint is Number.

> > How can I call it with a hint... by doing something like
> > Number(myDate) or String(myDate)?

> The question is to which value you want to convert that object? When
> you answer on that question you can find way to do that conversion.
> See:
> <URL:http://www.jibbering.com/faq/faq_notes/type_convert.html/> By
> Richard Cornford.

What I wanted to do was have (''+new MyDate) give the same result as
(''+new Date), with (new MyDate) and (new Date) still giving the same
values for .toString() and .valueOf().

I managed to accomplish this by having (new MyDate).valueOf() return a
new Number object instead of a number primitive, which seems to force
toString() as the default value... you can probably explain how this
works much better than I can though.

http://groups.google.com/group/comp.lang.javascript/msg/204f2f2d2fdb5403