Q. What is the output of: console.log('5' + 3);

  • (A) 8
  • (B) 53
  • (C) NaN
  • (D) Error
πŸ’¬ Discuss
βœ… Correct Answer: (B) 53
Explanation: The + operator with a string and number results in string concatenation, so '5' + 3 = '53'.

Q. What will be the output of the following code?

Code:
console.log(2 + '2');
  • (A) 4
  • (B) 22
  • (C) NaN
  • (D) Error
πŸ’¬ Discuss
βœ… Correct Answer: (B) 22
Explanation: JavaScript coerces the number 2 to a string and concatenates, resulting in '22'.

Q. How do you define an arrow function in JavaScript?

  • (A) function => {}
  • (B) () => {}
  • (C) () =>
  • (D) => () {}
πŸ’¬ Discuss
βœ… Correct Answer: (B) () => {}
Explanation: The correct syntax for an arrow function is: () => {}

Q. What does '===' operator do in JavaScript?

  • (A) Assigns value
  • (B) Compares value and type
  • (C) Compares only value
  • (D) Checks if variable is defined
πŸ’¬ Discuss
βœ… Correct Answer: (B) Compares value and type
Explanation: '===' checks both value and data type for equality.

Q. Which built-in method reverses the elements of an array?

  • (A) flip()
  • (B) reverse()
  • (C) turn()
  • (D) back()
πŸ’¬ Discuss
βœ… Correct Answer: (B) reverse()
Explanation: The reverse() method reverses the order of array elements.

Q. What is the result of typeof NaN in JavaScript?

  • (A) number
  • (B) NaN
  • (C) undefined
  • (D) object
πŸ’¬ Discuss
βœ… Correct Answer: (A) number
Explanation: NaN is of type number in JavaScript, although it means Not-a-Number.

Q. Which of the following is not a JavaScript data type?

  • (A) Boolean
  • (B) Undefined
  • (C) Float
  • (D) Symbol
πŸ’¬ Discuss
βœ… Correct Answer: (C) Float
Explanation: JavaScript does not have a separate Float type; all numbers are of type Number.

Q. What will the following code print?

Code:
let a;
console.log(a);
  • (A) null
  • (B) undefined
  • (C) 0
  • (D) ReferenceError
πŸ’¬ Discuss
βœ… Correct Answer: (B) undefined
Explanation: A declared but uninitialized variable is 'undefined'.

Q. Which function is used to parse a string to an integer?

  • (A) parseInt()
  • (B) int()
  • (C) toInteger()
  • (D) Number.parse()
πŸ’¬ Discuss
βœ… Correct Answer: (A) parseInt()
Explanation: parseInt() is used to convert a string to an integer.

Q. What will the output be?

Code:
let x = [1, 2, 3];
let y = x;
y.push(4);
console.log(x);
  • (A) [1, 2, 3]
  • (B) [1, 2, 3, 4]
  • (C) [4]
  • (D) undefined
πŸ’¬ Discuss
βœ… Correct Answer: (B) [1, 2, 3, 4]
Explanation: Arrays are reference types, so modifying y also affects x.