ES6+ Features Interview Questions

    Question 1: let vs var

    What is the main difference between let and var?

    Question 2: const Declaration

    Which statement about const is correct?

    Question 3: Template Literals

    How do you create a string using template literals?

    Question 4: Default Parameters

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

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

    Question 5: Arrow Functions

    Which statement is true about arrow functions?

    Question 6: Destructuring Assignment

    What is the value of x after this code?

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

    Question 7: Spread Operator

    What does the following produce?

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

    Question 8: Object Property Shorthand

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

    Question 9: Rest Parameters

    Which function correctly uses rest parameters to accept multiple arguments?

    Question 10: Modules Export/Import

    How do you export a function in ES6 module?