Arrays
Arrays in Internet Object
Last updated
Was this helpful?
Arrays in Internet Object
Last updated
Was this helpful?
An array is represented by a pair of square brackets, which may contain zero or more values. It begins with an open square bracket ([ U+005B) and ends with a close square bracket (] U+005D). Each value is separated by commas (,
U+002C
). Essentially, an array is expressed as a sequence of values separated by commas enclosed in square brackets.
,
Comma
U+002C
Used as a value separator
[
Open Square Bracket
U+005B
Begins an array boundary
]
Close Square Bracket
U+005D
Closes an array boundary
Arrays can contain values of various types, including objects, other arrays, strings, numbers, boolean, and null.
A simple array of strings:
An array of objects:
An array with mixed values:
Arrays can be nested to create multi-dimensional data structures.
Two-dimensional arrays represent rows and columns:
Three-dimensional arrays represent collections of two-dimensional arrays:
An empty array is represented by a pair of square brackets with no values:
Empty values between array elements are not permitted. To include a missing value, you must explicitly specify a valid value such as null
. However, since the Internet Object specification neither assumes null
by default nor supports undefined
, any omission is strictly forbidden. Following are some examples of invalid array structures: