When using Object.keys() on an object with Symbol keys, these keys will __________ be included in the returned array.
- always
- sometimes
- never
- based on Object type
When using Object.keys() on an object with Symbol keys, the Symbol keys will never be included in the returned array. This is because Symbol-keyed properties are not enumerable and are ignored by Object.keys().
When calling a static method from another method in the same class, use the class name as a _________.
- reference
- keyword
- identifier
- namespace
In JavaScript, when calling a static method from within the same class, you use the class name as an identifier. This helps differentiate static methods from instance methods, which require an instance of the class.
__________ is a common pattern for dynamically loading modules based on user interactions.
- Lazy Loading
- Eager Loading
- Preloading
- Asynchronous Loading
Lazy loading is a common pattern in which modules are loaded only when they are actually needed, often based on user interactions or certain events, optimizing performance by loading resources on-demand.
Inside a template literal, the expression ${a + b} will __________ the values of a and b.
- Concatenate
- Add
- Multiply
- Evaluate
The expression ${a + b} inside a template literal will evaluate the values of 'a' and 'b'. It performs the specified operation (in this case, addition) and includes the result in the string.
_________ in ES6 Modules enables static analysis and optimization, a feature not present in CommonJS.
- Explicit Dependency Declaration
- Dynamic Dependency Resolution
- Tree Shaking
- Lazy Loading
Tree Shaking in ES6 Modules allows for the removal of unused code during the build process, leading to smaller bundle sizes. This feature is not available in CommonJS, highlighting the advantages of ES6 modules.
The WeakSet does not have a _______ method which is available in a regular Set.
- size
- delete
- clear
- add
The WeakSet does not have a 'clear' method, which is available in a regular Set. The 'clear' method in a Set is used to remove all elements from the Set, but WeakSet lacks this functionality.
Can you use both named and default exports in the same ES6 module?
- Yes
- No
- Only if the module is in strict mode
- Only if the named exports are functions
Yes, you can use both named and default exports in the same ES6 module. This allows you to export a single "default" value along with multiple named exports from the same module.
Can an arrow function have its own this context?
- Yes, it has its own this context
- No, it shares the this context with the surrounding code
- Yes, but it inherits the this context from the parent scope
- No, it always refers to the global object
Yes, an arrow function has its own this context, which means it does not bind its own this but retains the this value of the enclosing lexical scope. This behavior can be advantageous in certain scenarios.
Template literals are enclosed by ________ characters.
- Single backtick (`)
- Double quotes (")
- Single quotes (')
- Dollar sign ($)
Template literals in ES6 are enclosed by backticks (`). This allows for easy embedding of variables and expressions using ${}.
What role does the event loop play in asynchronous operations in JavaScript?
- It handles user interactions
- It executes code in a non-blocking way
- It manages DOM events
- It controls the flow of synchronous code
The event loop in JavaScript manages the execution of asynchronous tasks. It ensures that non-blocking code is processed efficiently, allowing the program to remain responsive. Understanding the event loop is crucial for writing efficient asynchronous JavaScript code.