Q. What is the output of the following JavaScript code?

Code:
<script>
	var a = 10 + 20 + "5";
	document.getElementById("demo").innerHTML = a;
</script>
  • (A) 35
  • (B) 305
  • (C) TypeError
  • (D) ValueError
πŸ’¬ Discuss
βœ… Correct Answer: (B) 305

Q. What is the output of the following JavaScript code?

Code:
<script>
	let a = 10;
	let a = 0;
</script>
  • (A) 10
  • (B) 0
  • (C) SyntaxError
  • (D) TypeError
πŸ’¬ Discuss
βœ… Correct Answer: (C) SyntaxError

Q. Which is the exponentiation operator in JavaScript?

  • (A) exp()
  • (B) ^
  • (C) **
  • (D) pow
πŸ’¬ Discuss
βœ… Correct Answer: (C) **
Explanation:

In JavaScript, ** is the exponentiation operator used to raise a number to the power of another.
Example:

console.log(2 ** 3); // Output: 8

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

Code:
<script>
	var x = 5;
	document.getElementById("demo").innerHTML = x--;
</script>
  • (A) 5
  • (B) 4
  • (C) TypeError
  • (D) ValueError
πŸ’¬ Discuss
βœ… Correct Answer: (B) 4

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

Code:
<script>
	var x = 10 + 20 * 5;
	document.getElementById("tes").innerHTML = x;
</script>
  • (A) 110
  • (B) 150
  • (C) TypeError
  • (D) ValueError
πŸ’¬ Discuss
βœ… Correct Answer: (A) 110

Q. JavaScript arrays are written with _____.

  • (A) round brackets ()
  • (B) curly brackets {}
  • (C) double quotes ""
  • (D) square brackets []
πŸ’¬ Discuss
βœ… Correct Answer: (D) square brackets []

Q. JavaScript objects are written with _____.

  • (A) round brackets ()
  • (B) curly brackets {}
  • (C) double quotes ""
  • (D) square brackets []
πŸ’¬ Discuss
βœ… Correct Answer: (B) curly brackets {}

Q. Which JavaScript operator is used to determine the type of a variable?

  • (A) typeof
  • (B) TypeOf
  • (C) typeOf
  • (D) sizeof
πŸ’¬ Discuss
βœ… Correct Answer: (A) typeof

Q. Which is the correct syntax of JavaScript typeof operator?

  • (A) typeof variable/value
  • (B) typeof(variable/value)
  • (C) Both A and B.
  • (D) None of the above
πŸ’¬ Discuss
βœ… Correct Answer: (C) Both A and B.

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

Code:
<script>
	var x = 12.34;
	document.getElementById("test").innerHTML = typeof(x);
</script>
  • (A) int
  • (B) float
  • (C) long
  • (D) number
πŸ’¬ Discuss
βœ… Correct Answer: (D) number