## Method #1

We can use the double-asterisk operator ** – it is “Exponentiation Operator”.

In an Exponentiation Expression, we have to specify the number we want to square to the left of the ** operator, and to the right of the ** operator, we have to write number 2, which stands for the second power (i.e. the square).

```3**2
9

4**2
16

5**2
25

111111**2
12345654321```

## Method #2

To square a number in JavaScript, use the pow() method of the Math constructor.

The first parameter is the number to be squared. The second parameter is the number 2, which is the second power (square).

```Math.pow(0, 2)
0```
```Math.pow(1, 2)
1```
```Math.pow(2, 2)
4```
```Math.pow(3, 2)
9```
```Math.pow(4, 2)
16```

In the same way, you can take a number to the cube, and to any other degree.

#### Information references

ECMAScript Standard – Section “13.6 Exponentiation Operator” – https://tc39.es/ecma262/#sec-exp-operator

ECMAScript Standard – Section “21.3.2.26 Math.pow ( base, exponent )” – https://tc39.es/ecma262/#sec-math.pow

## How To Combine Javascript Files

I want to create a compiled JavaScript file for my website. For development, I would prefer to keep…

## What Does Return Do In Javascript

Table of Contents Hide Why return is needed in JavaScript functionsReturn a string, number or other data typeReturn…

## How To Pass Data From One Page To Another In Html Using Javascript

Table of Contents Hide Automatic JavaScript redirect to another pageRedirect to another page after X secondsRedirect to another…

## How To Make A Circle In Javascript

The following arc method draws an arc centered at some point. It takes the following parameters: x, y,…

## How To Display Text In Javascript

In this tutorial, we’ll look at how to display text in JavaScript, with two different purposes: replace it…