ES6+ Features Interview Questions

    Question 1let vs var

    What is the main difference between let and var?

    Question 2const Declaration

    Which statement about const is correct?

    Question 3Template Literals

    How do you create a string using template literals?

    Question 4Default Parameters

    What will add(5) return if the function is defined as:

    function add(a, b = 10) { return a + b; }

    Question 5Arrow Functions

    Which statement is true about arrow functions?

    Question 6Destructuring Assignment

    What is the value of x after this code?

    let [x, y] = [10, 20];

    Question 7Spread Operator

    What does the following produce?

    let arr1 = [1, 2]; let arr2 = [...arr1, 3, 4];

    Question 8Object Property Shorthand

    What is the shorthand syntax for { name: name, age: age }?

    Question 9Rest Parameters

    Which function correctly uses rest parameters to accept multiple arguments?

    Question 10Modules Export/Import

    How do you export a function in ES6 module?