Object Number in JavaScript

The Number object represents the date in the form of a numeric value, or an integer or floating-point number. Generally, you don't need to worry about Number objects because the browser automatically converts number literals to illustrate the number classes.

Syntax

Syntax to create a Number object as follows:

 var val = new Number ( number ); 

In the position of number, if you provide any non-numeric value, then the parameter cannot be converted to a number, it returns NaN (short for Not-a-Number).

The properties of Number

Below is a list of its attributes and descriptions.

Properties Description

MAX_VALUE

The maximum possible value of some in JavaScript can be up to 1.7976931348623157E + 308

MIN_VALUE

The smallest possible value of some in JavaScript can reach 5E-324

NaN

Equivalent to value that is not a number

NEGATIVE_INFINITY

A value less than MIN_VALUE

POSITIVE_INFINITY

A value greater than MAX_VALUE

prototype

Static attribute of Number object. Use the prototype property to assign new properties and methods to the Number object in the current document

constructor

Returns the function that creates the illustration of this object. By default, it is the Number object

The methods of Number

The Number object contains only the default methods that are part of each object definition.

Method Description

toExponential ()

Make some impressions in exponential form, even if this number is in a range in which JavaScript often uses standard notation.

toFixed ()

A number format with a specific number of digits to the right of the decimal part.

toLocaleString ()

Returns a string value version of the current number in a format that can be varied according to the browser internal setting.

toPrecision ()

Define how many digits (including the digits on the right and left of the decimal part) to display a number.

toString ()

Returns the string representation of the numeric value.

valueOf ()

Returns the value of the number.

According to Tutorialspoint

Previous article: Objects in JavaScript

Next lesson: Boolean object in JavaScript

3.5 ★ | 2 Vote

May be interested

  • How to turn on and turn off Javascript on Firefox, ChromeHow to turn on and turn off Javascript on Firefox, Chrome
    javascript is an object-based scripting language that often creates eye-catching effects on websites.however, if you need to turn on or off javascript, the following article will guide you to do that.
  • Summary of JavaScript exercises with sample codeSummary of JavaScript exercises with sample code
    in order to make your javascript learning easier, tipsmake.com has compiled a number of javascript exercises with sample solutions for you to practice.
  • Regular Expression and RegExp in JavaScriptRegular Expression and RegExp in JavaScript
    a regular expression is an object that describes a pattern of characters.
  • Boolean objects in JavaScriptBoolean objects in JavaScript
    boolean objects represent two values, either true or false. if the value parameter is omitted either 0, -0, null, false, nan, undefined, or an empty string (), the object has an initial value of false.
  • Array (Array) in JavaScriptArray (Array) in JavaScript
    array object - array helps you store multiple values ​​in a single variable. it stores a set of fixed-size ranges of elements in the same type (type). an array is used to store a data set, but it is often more useful to think of an array as a collection of variables in the same type.
  • Math object in JavaScriptMath object in JavaScript
    the math object gives you properties and methods for constants and mathematical functions. unlike other global objects, math is not a constructor. all properties and methods of math are static (static) and can be called using math as an object without having to create it.
  • What is JavaScript? Can the Internet exist without JavaScript?What is JavaScript?  Can the Internet exist without JavaScript?
    not everyone knows what javascript is and how it works. the long and fascinating development history of javascript as well as what we can do with javascript is still unknown.
  • What is Currying in Javascript? How to use Currying in JavaScriptWhat is Currying in Javascript? How to use Currying in JavaScript
    the currying feature in javascript can help you keep your code tidy and give you a new way of seeing how functions work. currying is ideal when you want to break complex logic into smaller, manageable, and self-contained pieces of code.
  • Things to know about 'this' in JavaScriptThings to know about 'this' in JavaScript
    are you having trouble understanding the keyword 'this' in javascript ? then please read what you need to know about 'this' in javascript below.
  • Basic about jQueryBasic about jQuery
    this article will explain the basic concepts commonly used in jquery such as: string (string), number (number), boolean, array (array), function, parameter, context, ...