JSON Quick Syntax Reference by Wallace Jackson

JSON Quick Syntax Reference by Wallace Jackson

Author:Wallace Jackson
Language: eng
Format: epub, pdf
Publisher: Apress, Berkeley, CA


Now that you have defined an array of data objects, let’s look at how you access elements of arrays using the array name, element indices, object properties, and dot notation.

Accessing a JavaScript Array: Using the Index

Array data elements are accessed by using their indices, which are contained in square brackets just like the array itself. As you may imagine, the array name comes first, using an integer index specification, to specify which data record you wish to access. Then the dot-notation syntax is used to chain together that data record with the property name you wish to reference. The following example puts together a construct that accesses the first (carName) object attribute ("Toyota"):

carInventory[0].carName // Will return the String value: "Toyota"



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.