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

## Description

In JavaScript, sign() is a characteristic that is used to return a cost indicating the signal of a number. Because the sign() function is a static feature of the Math object, it must be invoked via the placeholder object known as Math.

## Syntax

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

`Math.sign(number);`

Parameters or Arguments

number

The number to test for its sign.

## Returns

The sign() feature returns 1 if the range is increased than zero

The sign() characteristic returns 0 if the range is equal to zero

The sign() characteristic returns -1 if the variety is less than 0

## Note

Math is a placeholder object that includes mathematical functions and constants of which sign() is one of these functions.

## Example

Let’s take a appear at an instance of how to use the sign() characteristic in JavaScript.

For example:

```
console.log(Math.sign(32));
console.log(Math.sign(0));
console.log(Math.sign(-4));
```

In this example, we have invoked the sign() feature the use of the Math class.

We have written the output of the sign() function to the internet browser console log, for demonstration purposes, to exhibit what the sign() function returns.

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

```
1
0
-1
```

In this example, the first output to the console log returned 1 on the grounds that the value 32 is a variety larger than 0 (ie: a high quality number).

The 2d output to the console log lower back 0 considering the fact that the value 0 is equal to 0

The third output to the console log again -1 considering the fact that the fee -4 is a number much less than zero (ie: a poor number).

## Leave a Review