Optional argument types

Andrea Giammarchi andrea.giammarchi at gmail.com
Tue Sep 25 12:53:17 PDT 2012


Dmitry I think in this view the proposal having "primitives" rather than
instanceof makes more sense and is probably what you need, right?

string s won't accept instanceof String, that's what you want ... 'cause
you don't want pointless objects wrappers around neither, isn't it?

You want function, string, boolean, undefined, number, and object ... which
are all universally valid, included the null as object when nullable is
desirable, isn't it? This should cover 80% of use cases already without
much effort.

Anyway, the good part of JavaScript is that you can wrap everything runtime
and debug it without problems during assignment so that you can create a
function wrapper able to define a behavior and disable this behavior in
production, as suggested in my 2007 post about strict type JavaScript .. is
a wrapper for function, gonna work for these cases too and the way you
expect/want.

I still would like to know why the typeof, as hint, is a bad idea thought
:-)

br


On Tue, Sep 25, 2012 at 8:09 PM, Dmitry Soshnikov <
dmitry.soshnikov at gmail.com> wrote:

>
> In this view, yes, JS is not ready to go with this in production and at
> standard level. And as for custom projects -- then, that's said, can solve
> this issue in own manner with pre-processors.
>
> Thanks again,
>
> Dmitry
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120925/03108536/attachment.html>


More information about the es-discuss mailing list