Variable Scope in Functions
What will be the output of the following code: var a = 5; function test() { var a = 10; console.log(a); } test();
- 10
- 5
- undefined
- ReferenceError
- 'a'
Understanding typeof Operator
What is the result of typeof null in JavaScript?
- 'object'
- 'null'
- 'undefined'
- 'Null'
- 'none'
Implicit Type Coercion
What is the output of this expression: '2' + 2 + 2?
- '222'
- 6
- '24'
- '22'
- NaN
Closures in JavaScript
Which of the following best describes a closure in JavaScript?
- A function with access to its own scope, the outer function's scope, and the global scope
- A variable that stores a list of functions
- A method to create private variables only in classes
- An array that stores other arrays
- A function that is immediately invoked after definition
Array Methods
Given: var arr = [1, 2, 3]; After arr.push(4), what is arr?
- [1, 2, 3, 4]
- [4, 1, 2, 3]
- [1, 2, 3, 4, undefined]
- [1, 2, 3]
- [1, 4, 2, 3]
Equality Comparison
What is the result of this JavaScript expression: 0 == '0'?
- true
- false
- undefined
- null
- '0'
Arrow Functions Syntax
Which option correctly creates an arrow function that doubles a number?
- x =u003E x * 2
- (x) =u003E x * 2
- function(x) =u003E { x * 2 }
- x -u003E x * 2
- double(x) x * 2
Primitive vs Reference Types
What happens when you compare two distinct arrays with the same elements using ===?
- false
- true
- undefined
- Throws an error
- 'arrays are same'
Hoisting Behavior
What will be logged: console.log(b); var b = 4;
- undefined
- 4
- ReferenceError
- null
- 'b'
ParseInt Function Quirks
What is the result of parseInt('08') in JavaScript?
- 8
- 0
- NaN
- undefined
- '8'