Promise Polyfill Functionality
In JavaScript, what is the primary purpose of a Promise polyfill?
- To provide Promise functionality in environments where Promises are not natively supported
- To automatically retry asynchronous code on failure
- To handle CSS animations efficiently
- To polyfill only arrow functions
- To add types to all promise-based functions
Arrow Function Syntax
Which one of the following is the correct way to write an arrow function that returns the sum of two numbers 'a' and 'b'?
- (a, b) =u003E a + b
- function(a, b) =u003E { return a + b; }
- [a, b] =u003E { return a + b }
- a, b -u003E a + b
- (a; b) =u003E { return a + b }
Identifying Closures
What is a closure in JavaScript?
- A function having access to its own scope, the outer function's scope, and the global scope
- A way to close the browser tab automatically
- A block of code that runs immediately after it is defined
- An error handling mechanism
- A pre-compiled JavaScript file
Async and Await
What does the 'await' keyword do inside an 'async' function in JavaScript?
- It pauses the execution until the promise is resolved
- It runs the code synchronously
- It throws an error if the promise is rejected
- It creates a new thread
- It defines a global variable
LRUCache Implementation
Which feature does a typical Least Recently Used (LRU) cache provide?
- Removes the least recently accessed entry when the maximum size is reached
- Always keeps the oldest entry regardless of access
- Caches only successful network requests
- Uses only weak references to stored objects
- Ignores duplicate cache keys
Higher-Order Functions
What is a higher-order function in JavaScript?
- A function that takes another function as an argument or returns a function
- A function that always executes asynchronously
- A function that is hoisted to the top of its scope
- A function with infinite recursion
- A function only usable inside classes
Object.entries() Usage
What does Object.entries(obj) return in JavaScript?
- An array of key-value pairs from the object
- A list of all values of the object
- A function reference to the object constructor
- A sorted array of object keys
- An iterable of prototype methods
Identifying Asynchronous Patterns
Which of the following is NOT a recognized asynchronous programming pattern in JavaScript?
- Thread locks
- Promises
- Callbacks
- Async functions
- Event listeners
Code Output: String Manipulation
Given the code snippet: const result = 'hello'.split('').reverse().join(''); What is the value of 'result'?
- olleh
- hello
- hellohello
- ehllo
- heoll
Dictionary Lookups in JavaScript
In JavaScript, which approach checks if a string 'word' exists as a key in a given dictionary object called 'dict'?
- 'word' in dict
- dict.hasString(word)
- word == dict.key
- dict[word] = true;
- dict.includes(word)