Question:

What will be the output of the following JavaScript code?
<html> <body> <script> document.write(Math.pow(3,2)); </script> </body> </html>

Show Hint

In modern JavaScript (ES6+), you can also use the exponentiation operator () to achieve the exact same result: 3 2 evaluates to 9.
Updated On: Jun 29, 2026
  • 4
  • 9
  • 6
  • 8
Show Solution
collegedunia
Verified By Collegedunia

The Correct Option is B

Solution and Explanation



Step 1: Analyzing the Math.pow()
Built-in Method:
The Math.pow(base, exponent) static method returns the base raised to the power of the exponent. It calculates: $$\text{Output} = \text{base}^{\text{exponent}}$$

Step 2: Calculating with Given Arguments:

In the given snippet, the arguments are:
• $\text{base} = 3$
• $\text{exponent} = 2$ This maps to the mathematical expression: $$\text{Output} = 3^2 = 3 \times 3 = 9$$

Step 3: Output Display:

The document.write() method outputs the numeric value $9$ directly to the parsed HTML stream, rendering it on the web page.
Was this answer helpful?
0
0