Advanced JavaScript

Last Updated :
Discuss
Comments

Question 1

What is the call stack in JavaScript?

  • A

    A data structure to store variable names

  • B

    A data structure that manages function execution contexts

  • C

    A function that executes asynchronous code

  • D

    A method to clear all function calls

Question 2

What will the following code log?

JavaScript
console.log(a);
var a = 10;


  • A

    10

  • B

    undefined

  • C

    Error

  • D

    null

Question 3

Which of the following statements about closures is true?

  • A

    A closure is created only when using this.

  • B

    A closure allows a function to access variables from its lexical scope.

  • C

    Closures are not allowed in arrow functions.

  • D

    Closures are created during runtime only.

Question 4

What is the purpose of the 'this' keyword in the global execution context?

  • A

    Refers to the current object

  • B

    Refers to the global object

  • C

    Refers to the parent function

  • D

    Refers to the currently executing function

Question 5

What will the following code log?

JavaScript
function outer() {
    let a = 10;
    return function inner() {
        console.log(a);
    };
}
const fn = outer();
fn();


  • A

    undefined

  • B

    10

  • C

    Error

  • D

    null

Question 6

What is a key feature of WeakMap in JavaScript?

  • A

    Keys must be strings.

  • B

    Keys are weakly referenced and cannot be primitive values.

  • C

    Values are immutable.

  • D

    It supports iteration.

Question 7

What will the following generator function output?

JavaScript
function* generator() {
    yield 1;
    yield 2;
    yield 3;
}
const gen = generator();
console.log(gen.next().value);


  • A

    1

  • B

    2

  • C

    undefined

  • D

    Error

Question 8

Which of the following is a characteristic of a pure function?

  • A

    Modifies global variables

  • B

    Always produces the same output for the same input

  • C

    Depends on external state

  • D

    Throws an error if input is invalid

Question 9

What is currying in functional programming?

  • A

    Breaking a function into smaller functions

  • B

    Transforming a function to take multiple arguments into one that takes them one at a time

  • C

    Chaining multiple function calls

  • D

    Combining multiple functions into a single function

Question 10

What will the following code log?

JavaScript
const n = [1, 2, 3];
const doubled = n.map((n) => n * 2);
console.log(doubled);


  • A

    [2, 4, 6]

  • B

    [1, 2, 3]

  • C

    [4, 8, 12]

  • D

    Error

There are 10 questions to complete.

Take a part in the ongoing discussion