Tuesday, 15 April 2014

arrays - How can I count data2.length with JavaScript? -



arrays - How can I count data2.length with JavaScript? -

i'm working facebook graph api , facing 2 kind of arrays. can tell me different between them?

<script type="text/javascript"> var data1 = ["apple", "orange", "coconut"]; var data2 = {"apple", "orange", "coconut"}; </script>

what different between [] , {} in json? why data2.length doesn't work? how can count data2.length javascript??

seems off-topic need know counting data2 length. there anyway?

when declare var [], it's array of elements. can of single elements or array of objects. data1 array of simple elements (like in case, array of strings). that's why can length of data1 successfully. when declare variable {} means declaring object , not array.

javascript arrays json

No comments:

Post a Comment