Skip to main content
Update link to MDN page on Array Object
Source Link
Barmar
  • 769.5k
  • 54
  • 527
  • 641
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

JSON is a textual representation of data, just like XML, YAML, CSV, and others. To work with such data, it first has to be converted to JavaScript data types, i.e. arrays and objects (and how to work with those was just explained). How to parse JSON is explained in the question Parse JSON in JavaScript?Parse JSON in JavaScript? .

One could also use for...in to iterate over arrays, but there are reasons why this should be avoided: Why is 'for(var item in list)' with arrays considered bad practice in JavaScript?Why is 'for(var item in list)' with arrays considered bad practice in JavaScript?.

JSON is a textual representation of data, just like XML, YAML, CSV, and others. To work with such data, it first has to be converted to JavaScript data types, i.e. arrays and objects (and how to work with those was just explained). How to parse JSON is explained in the question Parse JSON in JavaScript? .

One could also use for...in to iterate over arrays, but there are reasons why this should be avoided: Why is 'for(var item in list)' with arrays considered bad practice in JavaScript?.

JSON is a textual representation of data, just like XML, YAML, CSV, and others. To work with such data, it first has to be converted to JavaScript data types, i.e. arrays and objects (and how to work with those was just explained). How to parse JSON is explained in the question Parse JSON in JavaScript? .

One could also use for...in to iterate over arrays, but there are reasons why this should be avoided: Why is 'for(var item in list)' with arrays considered bad practice in JavaScript?.

deleted 6 characters in body
Source Link
Felix Kling
  • 810.7k
  • 176
  • 1.1k
  • 1.2k

In addition to unknown keys, the "depth" of the data structure (i.e. how many nested objects per array) it has, might be unknown as well. How to access deeply nested properties usually depends on the exact data structure, then?.

IfBut if the data structure contains repeating structurespatterns, e.g. the representation of a binary tree, the solution typically includes to recursively [Wikipedia] access each level of the data structure.

In addition to unknown keys, the "depth" of the data structure (i.e. how many nested objects per array) it has, might be unknown as well. How to access deeply nested properties depends on the exact data structure, then?

If the data structure contains repeating structures, e.g. the representation of a binary tree, the solution typically includes to recursively [Wikipedia] access each level of the data structure.

In addition to unknown keys, the "depth" of the data structure (i.e. how many nested objects) it has, might be unknown as well. How to access deeply nested properties usually depends on the exact data structure.

But if the data structure contains repeating patterns, e.g. the representation of a binary tree, the solution typically includes to recursively [Wikipedia] access each level of the data structure.

small typo, ES2015 is also known as ES6, not ES5
Source Link
Dez
  • 5.8k
  • 8
  • 45
  • 52
Loading
added 95 characters in body
Source Link
Loading
added 87 characters in body
Source Link
Felix Kling
  • 810.7k
  • 176
  • 1.1k
  • 1.2k
Loading
Add more info about iteration; some formatting for better readability
Source Link
Felix Kling
  • 810.7k
  • 176
  • 1.1k
  • 1.2k
Loading
Add info about `Object.keys`
Source Link
Felix Kling
  • 810.7k
  • 176
  • 1.1k
  • 1.2k
Loading
replace jsfiddle demos with stack snippets
Source Link
Felix Kling
  • 810.7k
  • 176
  • 1.1k
  • 1.2k
Loading
added 113 characters in body
Source Link
Felix Kling
  • 810.7k
  • 176
  • 1.1k
  • 1.2k
Loading
A few light readability tweaks
Source Link
isherwood
  • 60.5k
  • 16
  • 119
  • 164
Loading
deleted 1 character in body
Source Link
Bergi
  • 655.3k
  • 156
  • 998
  • 1.4k
Loading
added 237 characters in body
Source Link
Felix Kling
  • 810.7k
  • 176
  • 1.1k
  • 1.2k
Loading
added 102 characters in body
Source Link
Felix Kling
  • 810.7k
  • 176
  • 1.1k
  • 1.2k
Loading
added info about `forEach`
Source Link
Felix Kling
  • 810.7k
  • 176
  • 1.1k
  • 1.2k
Loading
added 488 characters in body
Source Link
Felix Kling
  • 810.7k
  • 176
  • 1.1k
  • 1.2k
Loading
added 21 characters in body
Source Link
Felix Kling
  • 810.7k
  • 176
  • 1.1k
  • 1.2k
Loading
mentioned recursion
Source Link
Felix Kling
  • 810.7k
  • 176
  • 1.1k
  • 1.2k
Loading
added explanation for console output; added 2 characters in body
Source Link
Felix Kling
  • 810.7k
  • 176
  • 1.1k
  • 1.2k
Loading
added 10 characters in body
Source Link
Felix Kling
  • 810.7k
  • 176
  • 1.1k
  • 1.2k
Loading
added information about loops
Source Link
Felix Kling
  • 810.7k
  • 176
  • 1.1k
  • 1.2k
Loading
deleted 10 characters in body
Source Link
Felix Kling
  • 810.7k
  • 176
  • 1.1k
  • 1.2k
Loading
added 397 characters in body; deleted 1 characters in body; deleted 11 characters in body; deleted 9 characters in body
Source Link
Felix Kling
  • 810.7k
  • 176
  • 1.1k
  • 1.2k
Loading
added 589 characters in body; added 38 characters in body; added 2 characters in body
Source Link
Felix Kling
  • 810.7k
  • 176
  • 1.1k
  • 1.2k
Loading
Source Link
Felix Kling
  • 810.7k
  • 176
  • 1.1k
  • 1.2k
Loading