Numbers in JavaScript

JavaScritp numbers are basically used to represent the numeric values. It may be integer or floating-point. JavaScript number object follows IEEE standard to represent the floating-point numbers.

Example of Numbers in JavaScript

A JavaScript string is zero or more characters written inside quotes.
You can use single or double quotes:

var x=102;//integer value  
var y=102.7;//floating point value  
var z=13e4;//exponent value, output: 130000  
var n=new Number(16);//integer value by number object  
        

JavaScript Number Constants

Let's see the list of JavaScript number constants with description.

Constant Description
MIN_VALUE This costant is used to returns the largest minimum value in JavaScript.
MAX_VALUE This costant is used to returns the largest maximum value in JavaScript.
POSITIVE_INFINITY This costant is used to returns positive infinity, overflow value in JavaScript.
NEGATIVE_INFINITY This costant is used to returns negative infinity, overflow value in JavaScript.
NaN This costant is used to represents "Not a Number" value in JavaScript.

JavaScript Number Methods

Let's see the list of JavaScript number methods with their description.

Methods Description
isFinite() This method determines whether the given value is a finite number in JavaScript.
isInteger() This method determines whether the given value is an integer in JavaScript.
parseFloat() This method converts the given string into a floating point number in JavaScript.
parseInt() This method converts the given string into an integer number in JavaScript.
toExponential() This method returns the string that represents exponential notation of the given number in JavaScript.
toFixed() This method returns the string that represents a number with exact digits after a decimal point in JavaScript.
toPrecision() This method returns the string representing a number of specified precision in JavaScript.
toString() This method returns the given number in the form of string in JavaScript.

Note:

JavaScript uses the + operator for both addition and concatenation.
Numbers are added. Strings are concatenated.








The Best

Comment here

If you have any query, if you want to know something about any of technical course related to computer science field, if you have any suggestion about relevant to uploaded content or if you anything wrong here (any mistake in content) than please contact us. Keep in mind, comment should be according to community guidelines.