Question 1
What is the index of the first element in a JavaScript array?
1
0
-1
undefined
Question 2
What is the output of the following code?
let a = [10, 20, 30];
console.log(a[1]);
10
20
30
undefined
Question 3
Which method is used to add an element to the beginning of an array?
push()
pop()
unshift()
shift()
Question 4
What does the following code do?
let a = [1, 2, 3];
a.length = 2;
console.log(a);
[1, 2]
[2, 3]
[1, 2, 3]
[1, 2, 3,
Question 5
Which of the following methods modifies the original array?
concat()
slice()
reverse()
toString()
Question 6
What will be the output of the following code?
let a = [10, 20, 30];
console.log(a.pop());
30
10
Undefined
Error
Question 7
How do you check if a variable a is an array?
typeof a === 'array'
Array.isArray(a)
a instanceof Object
a.constructor === Array
Question 8
What does the splice() method do?
Adds elements to the end
Removes elements from the array
Adds and removes elements
Merges two arrays
Question 9
What is the result of the following code?
console.log([] + []);
NaN
""
[]
undefined
Question 10
What does a closure in JavaScript do?
Accesses outer function variables
Only accesses global variables
Is not useful in async code
Can't access outer variables
There are 10 questions to complete.