0

So, I have this array with attributes and i want to get its' length. In this case the array length should be 2 since there are only 2 "items"

 {"items":[{"value":"2","valor":0,"name":"Limpeza"},
 {"value":"6","valor":0,"name":"TECREMOVE"}]}

I've already tried exist.length but it returns undefined. How can i get its' length?

asked Jul 3, 2013 at 10:21

2 Answers 2

2
var myObj = {"items":[{"value":"2","valor":0,"name":"Limpeza"},
 {"value":"6","valor":0,"name":"TECREMOVE"}]};
var arrLength = myObj.items.length;

myObj.items - is the array, myObj.items.length - length of that array.

answered Jul 3, 2013 at 10:23

1 Comment

worked perfectly, thank you.(i'll accept the answer as soon as possible)
1

You're having an object which one of it's properties with the name items is an array with the length of 2.

Try:

var data = {"items":[{"value":"2","valor":0,"name":"Limpeza"},
 {"value":"6","valor":0,"name":"TECREMOVE"}]};
var len = data.items.length;
answered Jul 3, 2013 at 10:24

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.