Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 25th, 2012  |  syntax: None  |  size: 0.29 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How do i get count of an unknown attribute in a JSON object without a loop
  2. var myObject = {
  3.     'item_123': {
  4.         'id': 1,
  5.         'name': 'Some name'
  6.     },
  7.     'item_789': {
  8.         'id': 2,
  9.         'name': 'Another name'
  10.     }
  11. };
  12.        
  13. var objItemCount = Object.keys(myObject).length