Using Math pow() function to coding in Javascript/JS

This JavaScript tutorial explains how to use the math characteristic referred to as pow() with syntax and examples.

Description

In JavaScript, pow() is a feature that is used to return m raised to the nth power. Because the pow() function is a static characteristic of the Math object, it should be invoked via the placeholder object called Math.

Syntax

In JavaScript, the syntax for the pow() characteristic is:

Math.pow(m, n);

Parameters or Arguments

m The range used as the base in the calculation. n The variety used as the exponent in the calculation.

Returns

The pow() feature returns m raised to the nth electricity which is mn.

Note

Math is a placeholder object that consists of mathematical features and constants of which pow() is one of these functions.

Example

Let’s take a look at an instance of how to use the pow() feature in JavaScript.

For example:

console.log(Math.pow(5, 2));
console.log(Math.pow(5, -2));
console.log(Math.pow(4.6, 3));

In this example, we have invoked the pow() characteristic the usage of the Math class.

We have written the output of the pow() feature to the web browser console log, for demonstration purposes, to show what the pow() function returns.

The following will be output to the web browser console log:

25
0.04
97.33599999999997

In this example, the first output to the console log back 25 which is the calculation of fifty two

The second output to the console log back 0.04 which is the calculation of 5-2.

The third output to the console log again 97.33599999999997 which is the calculation of 4.63.