C
cognominal
I know that js is prototype based and not class based, that one can
dynamically add and remove properties and methodes in an object
and its prototype.
But I would like to be able to work in a more classy way (pun
unintended) and
ask the type of an object to know how to handle it.
For example, I would like to distinguish a mere array from an object
but typeof( [] ) and typeof( { key: "value" } both returns "object".
This is unsatisfying to me because they are certainly instances of a
different types
because I can do a push on the first and not on the second.
I could probably add a type property to the protype of my objects but I
would like to avoid to
badly redesign a wheel that certainly has already been done right
somewhere.
Can someone point me to a library?
Thanks in advance
dynamically add and remove properties and methodes in an object
and its prototype.
But I would like to be able to work in a more classy way (pun
unintended) and
ask the type of an object to know how to handle it.
For example, I would like to distinguish a mere array from an object
but typeof( [] ) and typeof( { key: "value" } both returns "object".
This is unsatisfying to me because they are certainly instances of a
different types
because I can do a push on the first and not on the second.
I could probably add a type property to the protype of my objects but I
would like to avoid to
badly redesign a wheel that certainly has already been done right
somewhere.
Can someone point me to a library?
Thanks in advance