Advanced JavaScript (original) (raw)
What is the call stack in JavaScript?
- A data structure to store variable names
- A data structure that manages function execution contexts
- A function that executes asynchronous code
- A method to clear all function calls
What will the following code log?
JavaScript `
console.log(a); var a = 10;
`
Which of the following statements about closures is true?
- A closure is created only when using this.
- A closure allows a function to access variables from its lexical scope.
- Closures are not allowed in arrow functions.
- Closures are created during runtime only.
What is the purpose of the 'this' keyword in the global execution context?
- Refers to the current object
- Refers to the global object
- Refers to the parent function
- Refers to the currently executing function
What will the following code log?
JavaScript `
function outer() { let a = 10; return function inner() { console.log(a); }; } const fn = outer(); fn();
`
What is a key feature of WeakMap in JavaScript?
- Keys are weakly referenced and cannot be primitive values.
What will the following generator function output?
JavaScript `
function* generator() { yield 1; yield 2; yield 3; } const gen = generator(); console.log(gen.next().value);
`
Which of the following is a characteristic of a pure function?
- Modifies global variables
- Always produces the same output for the same input
- Depends on external state
- Throws an error if input is invalid
What is currying in functional programming?
- Breaking a function into smaller functions
- Transforming a function to take multiple arguments into one that takes them one at a time
- Chaining multiple function calls
- Combining multiple functions into a single function
What will the following code log?
JavaScript `
const n = [1, 2, 3]; const doubled = n.map((n) => n * 2); console.log(doubled);
`
There are 10 questions to complete.
Take a part in the ongoing discussion