JavaScript Arrays Interview Questions

    Question 1: Array Type

    What is the result of typeof [] in JavaScript?

    Question 2: Array Length Property

    What will be the output of:

    let arr = [1, 2, 3]; console.log(arr.length);

    Question 3: Adding Elements with push()

    What is the result of:

    let arr = [1, 2]; arr.push(3); console.log(arr);

    Question 4: Removing Last Element

    What is the result of:

    let arr = [1, 2, 3]; arr.pop(); console.log(arr);

    Question 5: Removing First Element

    What is the result of:

    let arr = [10, 20, 30]; arr.shift(); console.log(arr);

    Question 6: Adding First Element

    What is the result of:

    let arr = [20, 30]; arr.unshift(10); console.log(arr);

    Question 7: Array Includes Check

    What will be the result of:

    let arr = [1, 2, 3]; console.log(arr.includes(2));

    Question 8: IndexOf Method

    What will be the result of:

    let arr = ["a", "b", "c"]; console.log(arr.indexOf("b"));

    Question 9: Array isArray Method

    What is the result of:

    console.log(Array.isArray([1, 2, 3]));

    Question 10: Array Concatenation

    What will be the result of:

    let a = [1, 2]; let b = [3, 4]; console.log(a.concat(b));