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);
- A: 1
- B: 2
- C: undefined
- D: null
- E: ReferenceError
Question 2
Which statement about closures in JavaScript is correct?
- A: Closures can only access variables declared with let.
- B: Closures allow a function to access variables from its parent scope even after the parent function has closed.
- C: Closures create copies of variables from the outer function's scope.
- D: Closures are destroyed immediately after the function executes.
- E: Closures cannot access global variables.
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();
- A: 1
- B: 2
- C: undefined
- D: It will throw an error
- E: NaN
Question 4
What is the result of the following expression in JavaScript? nn 0.1 + 0.2 === 0.3
- A: true
- B: false
- C: undefined
- D: 'true'
- E: TypeError
Question 5
Which of the following will NOT create a shallow copy of an array named arr in JavaScript?
- A: arr.slice()
- B: [...arr]
- C: Array.from(arr)
- D: arr.concat()
- E: arr.push()