Block Scope Variables
Which keyword creates a variable with block scope in JavaScript ES6?
- define
- function
- var
- let
- static
Constants Declaration
How do you declare a constant value that cannot be reassigned in JavaScript?
- const
- define
- constant
- perm
- let
Template Literals Usage
Which syntax allows embedding expressions inside strings, as in `The total is ${total}`?
- Template literals
- Backslash strings
- String addition
- String.concat
- Stringify
Object Destructuring
What is the result of `let { b } = { a: 1, b: 2 }` in JavaScript ES6?
- b = true
- b = 2
- b = undefined
- b = 1
- b = false
Swapping Variables
Which feature allows swapping variables like `[a, b] = [b, a]`?
- Array mapping
- Array destructuring
- Function arguments
- Property pulling
- Object mapping
Spread Operator With Arrays
What does `[...arr1, ...arr2]` do with two arrays in ES6?
- Creates a reference to arr1
- Deletes arr2
- Fills arr1 with undefined values
- Combines elements of both arrays
- Creates an object from arr2
Function Parameters With Rest
Which syntax allows a function to accept any number of arguments as an array?
- ...params
- ...items
- ...args
- varargs
- ...rest
Importing Named Exports
How do you import a named function `greet` from a module in ES6?
- import { greet } from './module'
- require greet from './module'
- bring greet from './module'
- fetch greet from './module'
- import greet from './module'
Default Export Import
Which syntax imports the default export from a module?
- import myFunc from './mod.js'
- import { myFunc } from './mod.js'
- import myFunc default './mod.js'
- import default myFunc from './mod.js'
- import * as myFunc from './mod.js'
Class Declaration
How do you define a class named `Car` in ES6?
- function Car() {}
- Car() {}
- class Car {}
- define class Car {}
- make Car {}
Class Constructors
Which method is used to initialize a new object's state in an ES6 class?
- initializer
- setup
- configure
- constructor
- initiate
Arrow Function Syntax
What is the correct arrow function syntax for `x =u003E x * 2`?
- x -u003E x * 2
- (x) : x * 2
- function(x) =u003E x * 2
- x =u003E x * 2
- lambda x: x * 2
Shorthand Property Names
If you have `let name = 'Sasha';`, how would you create an object with a property `name` using shorthand?
- { Sasha: name }
- { name: 'name' }
- { name = name }
- { name }
- { name: name }
Exporting Multiple Functions
How would you export two functions `a` and `b` from a module in ES6?
- exports a, b
- export { a, b }
- export functions a, b
- export default a, b
- module.exports = { a, b }
Rest Operator In Destructuring
In `[first, ...rest] = [1,2,3]`, what is the value of `rest`?
- [1, 3]
- 1
- 3
- [1, 2]
- [2, 3]