0

So... I looked at many tutorials and read many many posts and tutorials and all I could find was JavaScript arrays use brackets and arrays of objects are made of braces but nothing explained or mentioned the colons used in the code and I got a feeling that the code below is not an array of objects... Can anyone tell me exactly what the code below is in Laymen's terms?

var data = [{item: 'get milk'}, {item: 'walk dog'}, {item: 'kick some coding ass'}];
Jack Bashford
  • 38,499
  • 10
  • 36
  • 67
Mike Kim
  • 65
  • 6
  • Colons separate keys and values. `data[0].item` points to `'get milk'`. `data[1].item` is `'walk dog'`, ..etc. Good intro [here](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Basics) – Mark Jun 14 '19 at 21:57
  • I see. so data is an array in this case right? – Mike Kim Jun 14 '19 at 22:15
  • Yes, `data` is an array because of the square brackets. It's holding three objects each with one key/value pair. – Mark Jun 14 '19 at 22:16
  • 1
    ah..I see. that makes things very clear. thanks! – Mike Kim Jun 14 '19 at 22:17

0 Answers0