Is there any built-in function that can return the length of an object?

For example, I have a = { 'a':1,'b':2,'c':3 } which should return 3. If I use a.length it returns undefined.

It could be a simple loop function, but I’d like to know if there’s a built-in function?

There is a related question (Length of a JSON object) – in the chosen answer the user advises to transform object into an array, which is not pretty comfortable for my task.

15 Answers
15

Leave a Reply

Your email address will not be published. Required fields are marked *