JavaScript Number toExponential method - JavaScript Tutorial

JavaScript Number toExponential method

BLUF: This tutorial on JavaScript Number toExponential method provides an in-depth look at JavaScript's core features. It includes practical examples and code snippets to help you master modern JS development.
Key Discovery: JavaScript Number toExponential method

Understanding JavaScript Number toExponential method is crucial for building dynamic, interactive web applications. Explore the examples below to see it in action.

The toExponential method in JavaScript transforms a specified number into exponential notation and produces it as a string.

Syntax

The syntax for the toExponential method is depicted as follows:

Example

Number. toExponential(num)

Parameter

num - This parameter is optional. It denotes an integer that indicates the number of digits to be located following the decimal point.

Return

A string that signifies the exponential representation of the specified number.

JavaScript Number toExponential method example

In this section, we will explore the toExponential method by examining several examples.

Example 1

Let's examine a straightforward illustration of the toExponential function.

Example

<script>

var a=989721;

document.writeln(a.toExponential());

</script>

Output:

Output

9.89721e+5

Example 2

In this instance, we will provide an integer that indicates the number of digits to be positioned following the decimal point.

Example

<script>

var a=989721;

document.writeln(a.toExponential(2)+"<br>");

document.writeln(a.toExponential(4)+"<br>");

document.writeln(a.toExponential(6));

</script>

Output:

Output

9.90e+5

9.8972e+5

9.897210e+5

Input Required

This code uses input(). Please provide values below:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience