Javatpoint Logo
Javatpoint Logo

JavaScript Math sign() method

The JavaScript math sign() method returns the sign of the number. It indicates whether the given number is positive, negative or zero.

Syntax

The sign() method is represented by the following syntax:

Parameter

num - A number.

Return

The sign of the given number.

JavaScript Math sign() method example

Here, we will understand sign() method through various examples.

Example 1

Let's see an example to find out the sign of the given number.

Test it Now

Output:

1
-1
0

Example 2

Let's see some cases where sign() method returns NaN.

Test it Now

Output:

NaN
NaN
NaN

Example 3

Here, you can test sign() method with your own test cases.

Test it Now
Next TopicJavaScript Math





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA