I think that your function looks fine, ive just changed some little stuff:

http://www.jsfiddle.net/tvYQT/3/

i think you need to use getLength() (not sure) on the hash for example.

But if you could explain us why you need this kind of functionality, and
whats the problem your having, maybe we could come with a better solution.

Cheers,

--
Fábio Miranda Costa
Solucione Sistemas
Engenheiro de interfaces


On Thu, Feb 11, 2010 at 4:29 PM, אריה גלזר <[email protected]> wrote:

> i've been playing around with implementing a count method in JS, that will
> return the length of a given variable, no matter what it's type is.
> this is mainly useful for switching between array/object/string, but also
> might be interesting to see it work with elements.
> obviously, the main problem is how to handle types that have no distinct
> length, like functions, regexp etc.
>
> I've come up with this http://www.jsfiddle.net/tvYQT/1 as a proof of
> concept.
> What do you think? would you find this useful? how would you handle
> non-lengthy types?
> -----------
> אריה גלזר
> 052-5348-561
> 5561
>

Reply via email to