filmov
tv
JavaScript Demo: JSON Array of objects -- sorting on different fields & dynamic table creation

Показать описание
In this video we show how to designate an array of objects in JSON. The array is designated with square brackets []. The objects in the array are designated with curly brackets {} -- and come in a comma-separated list. Each object is defined by a set of key-value pairs with the key and value separated by a colon : and the pairs coming in a comma-separated list. We show how to sort the array of objects on different fields by defining a compare function for each different sort. Once we have the array sorted we use it to generate a dynamic table -- using createElement and appendChild methods.