In JavaScript, how do you access the third element of an array named myArray?
-
A
myArray[3]
-
B
myArray[2]
Correct answer
-
C
myArray[1]
-
D
myArray[0]
Correct answer
B. myArray[2]
13 views
Explanation
Array indexing starts at 0, so the third element is at index 2: myArray[2]. Source: Scribd, Class X Computer Science Exam (FBISE), Section A.
Reference
Asked in: Matric,FBISE
Doubts & discussion
Not sure why the answer is B? Ask here and get an explanation.
Ask a doubt about this MCQ