When a parameter is declared with a default value, its existence in the function's arguments array will be _________.
- TRUE
- FALSE
- undefined
- nan
When a parameter is declared with a default value, its existence in the function's arguments array will be false. Default parameters do not appear in the arguments object, and accessing them through the arguments object will return undefined.
An ES6 class method can be made private by prefixing its name with __________.
- private
- this
- protected
- underscore
In ES6, a class method can be made private by prefixing its name with an underscore. This convention signals to other developers that the method is intended for internal use and should not be accessed directly from outside the class. While not providing true privacy, it serves as a convention for indicating the method's intended visibility.
When chaining Promises in AJAX calls, what is the purpose of returning another Promise inside a .then() method?
- To allow further chaining of asynchronous operations
- To terminate the Promise chain
- To handle synchronous operations within the Promise
- To trigger a catch block if an error occurs in the Promise chain
In JavaScript, returning a Promise inside a .then() allows for continued chaining of asynchronous operations. This enables better organization and readability of asynchronous code.
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.
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.
What is a pure function in JavaScript?
- A function that has no side effects
- A function that modifies global variables
- A function that always returns the same output for the same input
- A function that has asynchronous operations
A pure function is a function that always produces the same output for the same input and has no side effects. It does not modify external state, and it does not rely on external state. This property makes pure functions predictable and easy to test.
Can static methods be called on instances of the class?
- Yes
- No
- It depends on how the static method is defined
- Only if the class is instantiated with the new keyword
Yes, static methods can be called on instances of the class. However, it is more common and recommended to call static methods on the class itself, as they are associated with the class, not with a specific instance.
How can you iterate over the elements of a Set in JavaScript?
- Using for...of loop, forEach method, map method, filter method
- forEach method, map method, for loop, for...in loop
- for loop, for...of loop, forEach method, map method
- for...of loop, forEach method, filter method, for loop
To iterate over the elements of a Set in JavaScript, you can use the for...of loop, which provides a concise and readable syntax for traversing the Set's values. Alternatively, you can also use the forEach method to execute a provided function once for each Set element, ensuring a clean and efficient iteration process.