Automation and ProgrammabilityDifficulty 2/5
Given {"vlans":[{"id":10,"name":"Sales"},{"id":20,"name":"Eng"}]}, what is the value of vlans[1].name?
- AEng
- B20
- CThe expression is invalid because vlans is an object
- DSales
Show answer and rationale
Correct: A. 'vlans' is an array (square brackets) of two objects. Arrays are zero-indexed, so vlans[1] is the second object and its 'name' is "Eng".
- D — That is vlans[0].name.
- B — 20 is vlans[1].id.
- C — Square brackets denote an array, so indexing is valid.