Mastering Advanced JavaScript: The Ultimate Self-Assessment Quiz Quiz

  1. Question 1

    In JavaScript, what will be logged to the console when executing the following code? nn let foo = { bar: 1 }; n Object.freeze(foo); n foo.bar = 2; n console.log(foo.bar);

    1. A: 1
    2. B: 2
    3. C: undefined
    4. D: null
    5. E: ReferenceError
  2. Question 2

    Which statement about closures in JavaScript is correct?

    1. A: Closures can only access variables declared with let.
    2. B: Closures allow a function to access variables from its parent scope even after the parent function has closed.
    3. C: Closures create copies of variables from the outer function's scope.
    4. D: Closures are destroyed immediately after the function executes.
    5. E: Closures cannot access global variables.
  3. Question 3

    Given the following code, which value will be shown by alert? nn var a = 1; n function f() { n var a = 2; n setTimeout(function() { alert(a); }, 0); n } n f();

    1. A: 1
    2. B: 2
    3. C: undefined
    4. D: It will throw an error
    5. E: NaN
  4. Question 4

    What is the result of the following expression in JavaScript? nn 0.1 + 0.2 === 0.3

    1. A: true
    2. B: false
    3. C: undefined
    4. D: 'true'
    5. E: TypeError
  5. Question 5

    Which of the following will NOT create a shallow copy of an array named arr in JavaScript?

    1. A: arr.slice()
    2. B: [...arr]
    3. C: Array.from(arr)
    4. D: arr.concat()
    5. E: arr.push()