JavaScirpt Tutorial Index

JavaScript Tutorial Javascript Example Javascript comment Javascript Variable Javascript Data Types Javascript Operators Javascript If Else Javascript Switch Statement Javascript loop JavaScript Function Javascript Object JavaScript Arrays Javascript String Javascript Date Javascript Math Javascript Number Javascript Dialog Box Javascript Window Object Javascript Document Object Javascript Event Javascript Cookies Javascript getElementByID Javascript Forms Validation Javascript Email Validation Javascript Password Validation Javascript Re-Password Validation Javascript Page Redirect Javascript Print

Misc

JavaScript P5.js JavaScript Minify JavaScript redirect URL with parameters Javascript Redirect Button JavaScript Ternary Operator JavaScript radio button checked value JavaScript moment date difference Javascript input maxlength JavaScript focus on input Javascript Find Object In Array JavaScript dropdown onchange JavaScript Console log Multiple variables JavaScript Time Picker Demo JavaScript Image resize before upload Functional Programming in JavaScript JavaScript SetTimeout() JavaScript SetInterval() Callback and Callback Hell in JavaScript Array to String in JavaScript Synchronous and Asynchronous in JavaScript Compare two Arrays in JavaScript Encapsulation in JavaScript File Type Validation while Uploading Using JavaScript or jquery Convert ASCII Code to Character in JavaScript Count Character in string in JavaScript Get First Element of Array in JavaScript How to convert array to set in JavaScript How to get current date and time in JavaScript How to Remove Special Characters from a String in JavaScript Number Validation in JavaScript Remove Substring from String in JavaScript

Interview Questions

JavaScript Interview Questions

Javascript Number

The Number object is a wrapper object which allows you to work with numerical values. The number object is created using the Number() constructor.It may be integer or floating-point. Syntax

var n=new Number(value);

Examples

<!DOCTYPE html>  
<html>  
<body>  
<script>  
var x=100;//integer value  
var y=100.7;//floating point value  
var z=12e5;//exponent value, output: 1200000  
var n=new Number(20);//integer value by number object    
document.write(x+" "+y+" "+z+" "+n);  
</script>  
</body>  
</html>
Try Now Output
100 100.7 1200000 20
Description The primary uses of the number object are:
  • If argument cannot be converted into a number, it returns NaN (Not a Number).
  • In a non-constructor context (i.e., without the new operator), Number can be used to perform a type conversion.

JavaScript Number Constants

Constant Description
MIN_VALUE It returns the largest minimum value.
MAX_VALUE It returns the largest maximum value.
POSITIVE_INFINITY It returns the positive infinity, overflow value.
NEGATIVE_INFINITY It returns the negative infinity, overflow value.
NaN It represent "Not a Number" value.