DevelopPHP
home Forum gear home

Libraries book

HTML Library CSS Library JavaScript Library PHP Library

Videosbook

PHP and MySQL JavaScript HTML and CSS Vector and 3D Flash Actionscript Android Dev Miscellaneous

Resourcesbook

Website Hosting
Number Object Javascript   Share / Like

The Javascript Number object sports a set of constants and methods for script authors when they work with numeric data.

Number Object Syntax

Javascript CODE EXAMPLE
var num1 = 5;
var num2 = Number(5);
var num3 = new Number(5);

All three of the approaches above are acceptable syntax for establishing a number in Javascript.

 

Constants(Properties) of the Number Object

MAX_VALUE - represents the maximum value
MIN_VALUE - represents the minimum value
NaN - represents not a number value
NEGATIVE_INFINITY - represents negative infinite value
POSITIVE_INFINITY - represents positive infinite value

Javascript CODE EXAMPLE
var v1 = Number.MAX_VALUE;
var v2 = Number.MIN_VALUE;
var v3 = Number.NaN;
var v4 = Number.NEGATIVE_INFINITY;
var v5 = Number.POSITIVE_INFINITY;

Properties of the number object are constants, which means they are values that do not change.

 

Methods of the Number Object

toExponential - returns exponential notation of a number
toFixed - returns fixed point notation of a number
toPrecision - returns fixed point notation to a specified precision
toString - return a string that represents the number(convert number to string object)
valueOf - return the primitive value of a number

Javascript CODE EXAMPLE
var num = 50;

var exn = num.toExponential(2);
var fix = num.toFixed(3);
var pre = num.toPrecision(5);
var str = num.toString();
var val = num.valueOf();

 

Home   •   Terms of Use   •   Developer Forums   •   T-Shirts   •   RSS   •   Classroom Chalkboard   •   Donate   •   Top ↑
Popular In PHP / MySQL E-Commerce Store Production
Social Network Website Building
Image Upload / Photo Processing
CMS Software Programming
Mass Email Systems
Magic XML Data
Search Programming
Popular In JavaScript JSON Programming
Ajax Programming
Animating Elements
WYSIWYG Programming
Date/Time Programming
DOM Scripting
Object Reference
Popular In HTML Canvas Element
New Form Elements
Audio Element
Video Element
Drag and Drop
Event Handling
Element Grouping
Popular In CSS Custom Font Embedding
Dynamic Fit Backgrounds
Theatre Mode
Box Overlays
CSS Level 1 Properties
CSS Level 2 Properties
CSS Level 3 Properties
©2013 DevelopPHP   |   Navigate to related domains HTML5