JavaScript ES6+ Essentials Quiz Quiz

  1. Block Scope Variables

    Which keyword creates a variable with block scope in JavaScript ES6?

    1. define
    2. function
    3. var
    4. let
    5. static
  2. Constants Declaration

    How do you declare a constant value that cannot be reassigned in JavaScript?

    1. const
    2. define
    3. constant
    4. perm
    5. let
  3. Template Literals Usage

    Which syntax allows embedding expressions inside strings, as in `The total is ${total}`?

    1. Template literals
    2. Backslash strings
    3. String addition
    4. String.concat
    5. Stringify
  4. Object Destructuring

    What is the result of `let { b } = { a: 1, b: 2 }` in JavaScript ES6?

    1. b = true
    2. b = 2
    3. b = undefined
    4. b = 1
    5. b = false
  5. Swapping Variables

    Which feature allows swapping variables like `[a, b] = [b, a]`?

    1. Array mapping
    2. Array destructuring
    3. Function arguments
    4. Property pulling
    5. Object mapping
  6. Spread Operator With Arrays

    What does `[...arr1, ...arr2]` do with two arrays in ES6?

    1. Creates a reference to arr1
    2. Deletes arr2
    3. Fills arr1 with undefined values
    4. Combines elements of both arrays
    5. Creates an object from arr2
  7. Function Parameters With Rest

    Which syntax allows a function to accept any number of arguments as an array?

    1. ...params
    2. ...items
    3. ...args
    4. varargs
    5. ...rest
  8. Importing Named Exports

    How do you import a named function `greet` from a module in ES6?

    1. import { greet } from './module'
    2. require greet from './module'
    3. bring greet from './module'
    4. fetch greet from './module'
    5. import greet from './module'
  9. Default Export Import

    Which syntax imports the default export from a module?

    1. import myFunc from './mod.js'
    2. import { myFunc } from './mod.js'
    3. import myFunc default './mod.js'
    4. import default myFunc from './mod.js'
    5. import * as myFunc from './mod.js'
  10. Class Declaration

    How do you define a class named `Car` in ES6?

    1. function Car() {}
    2. Car() {}
    3. class Car {}
    4. define class Car {}
    5. make Car {}
  11. Class Constructors

    Which method is used to initialize a new object's state in an ES6 class?

    1. initializer
    2. setup
    3. configure
    4. constructor
    5. initiate
  12. Arrow Function Syntax

    What is the correct arrow function syntax for `x =u003E x * 2`?

    1. x -u003E x * 2
    2. (x) : x * 2
    3. function(x) =u003E x * 2
    4. x =u003E x * 2
    5. lambda x: x * 2
  13. Shorthand Property Names

    If you have `let name = 'Sasha';`, how would you create an object with a property `name` using shorthand?

    1. { Sasha: name }
    2. { name: 'name' }
    3. { name = name }
    4. { name }
    5. { name: name }
  14. Exporting Multiple Functions

    How would you export two functions `a` and `b` from a module in ES6?

    1. exports a, b
    2. export { a, b }
    3. export functions a, b
    4. export default a, b
    5. module.exports = { a, b }
  15. Rest Operator In Destructuring

    In `[first, ...rest] = [1,2,3]`, what is the value of `rest`?

    1. [1, 3]
    2. 1
    3. 3
    4. [1, 2]
    5. [2, 3]