Which of the following JavaScript statements use arrays?
-
setTimeout("a["+i+"]",1000)
-
k = a & i
-
k = a(i)
Option A demonstrates array syntax using bracket notation a[i] within setTimeout. Options B and C use incorrect syntax - the & operator is bitwise AND, not array access, and a(i) uses function call syntax instead of array indexing. Only option A properly uses JavaScript array notation.
To answer this question, you need to understand how arrays are used in JavaScript.
An array is a special type of variable that can store multiple values in a single variable. It is created using square brackets [] and each value is separated by a comma.
Let's go through each option to understand which one uses arrays:
Option A) setTimeout("a["+i+"]",1000) - This option uses an array. The a variable is likely an array, and it is accessing the element at the index i using square brackets.
Option B) k = a & i - This option does not use arrays. It is using the bitwise AND operator (&) to perform a bitwise operation between variables a and i.
Option C) k = a(i) - This option does not use arrays. It is using parentheses () to call a function named a with the parameter i.
The correct answer is option A. This option uses an array to access an element at a specific index.