Objects in [[JavaScript]] are good data structures for storing multiple values as opposed to a simple array. The object is constructed with `object = { }` notation. You can add key, value pairs to the object with notation `object[key] = value`.
Here's an example of the use of an object to store responses to a form and then print them to the console.
```JavaScript title="JavaScript.html"
var formResponses = {}
formResponses['firstName'] = 'John';
formResponses['lastName'] = 'Smith';
console.log(formResponses.firstName, formResponses.lasName)
//"John"
//"Smith"
```
You can even assign functions to objects using the same notation.
Note that they syntax `formResponses['firstName']` is equivalent to the syntax `formResponses.firstName`.
One thing you might want to do is decompose an array into a JavaScript object. in this case a list of JavaScript objects (one for each row of data).
```JavaScript title="Code.gs"
function process_JSON(headers, data) {
var jsonArray = [];
// Loop through each data row
for (var i = 0; i < data.length; i++) {
var row = data[i];
var rowObject = {};
// Map each data header to its corresponding value in the row
for (var j = 0; j < headers.length; j++) {
if (row[j] !== null && row[j] !== undefined && row[j].toString().trim() !== '') {
rowObject[headers[j]] = row[j];
}
}
jsonArray.push(rowObject); // Add the row object (with metadata) to the array
}
return jsonArray;
}
```