Recursive functions can be used effectively for tasks such as __________ traversal in data structures.
- Depth-first
- Breadth-first
- Pre-order
- Post-order
Recursive functions are commonly employed for depth-first traversal, where the function explores as far as possible along each branch before backtracking.
For side effects only, import a module without any exported bindings using import '________';.
- module-name'
- {} from 'module-name'
- from 'module-name'
- module-name';
When importing a module for its side effects only, you can use import 'module-name'; without any specific binding. This is useful when a module has side effects like modifying the global scope.
ES6 allows the use of ________ to dynamically create property names in object literals.
- Template Literals
- Default Parameters
- Rest Parameters
- Spread Operator
Template literals in ES6 provide a powerful way to create strings, allowing dynamic expression evaluation. This feature is often used to create dynamic property names in object literals.
In ES6, can the rest operator be used in conjunction with destructuring to extract specific elements from an array?
- Yes, the rest operator allows extracting specific elements by using the spread syntax.
- No, the rest operator can only be used to extract all elements in an array.
- Yes, the rest operator can be combined with destructuring to extract specific elements.
- No, the rest operator is not compatible with array destructuring.
In ES6, the rest operator can indeed be used in conjunction with array destructuring to extract specific elements. It allows you to capture the remaining elements of an array into a new array variable.
When using default export, you can rename the imported module without using the _________ syntax.
- import customName from
- import as customName from
- import {customName} from
- import default as customName
In ES6, when importing a module with a default export and renaming it, you use the import customName from 'moduleName'; syntax. The as keyword is not required in this context.
What method is used to resume the execution of a generator function?
- resume()
- continue()
- next()
- run()
The correct method to resume the execution of a generator function is next(). This method is called on the Generator object and proceeds to the next yield statement, returning the yielded value. Options a), b), and d) are incorrect and not used for resuming a generator function.
Tagged template literals allow you to parse template literals with a _________ function.
- Regular
- Parse
- Tag
- Transform
In ES6, tagged template literals use a tag function to parse the template literal. This function, often referred to as the tag, allows you to process the template and its interpolated values before producing the final string.
How does the 'use strict' mode affect class behavior in ES6?
- It enforces stricter type checking in class properties
- It allows for dynamic addition of properties in a class
- It has no impact on class behavior
- It throws an error if the class contains undeclared variables
In 'use strict' mode, the class behavior becomes more rigid. It disallows the usage of undeclared variables, ensures that the 'this' keyword behaves more predictably, and generally promotes safer coding practices.
If a property is not found on an object, JavaScript looks up the property on the object's prototype, known as the _________ chain.
- Prototype
- Scope
- Inheritance
- Execution
In JavaScript, the process of searching for a property involves traversing the prototype chain. If the property is not found on the object, it looks up in the prototype chain until it finds the property.
In ES6, what is the difference between declaring methods in a class and in an object literal?
- Methods in a class are enumerable, while methods in an object literal are not
- Methods in a class are prototype methods, while methods in an object literal are not
- There is no difference between declaring methods in a class and in an object literal
- Methods in an object literal have access to the 'super' keyword
The key distinction is that methods in a class are prototype methods, meaning they are shared among all instances of the class. In contrast, methods in an object literal are not shared among instances.