Wednesday, November 9, 2016

Global Methods

JavaScript global methods can be used on all JavaScript data types.
 Number()      Returns a number, converted from its argument.
parseFloat()    Parses its argument and returns a floating point number
parseInt()       Parses its argument and returns an integer

x = true;
Number(x);        // returns 1


parseInt("10.33");      // returns 10


parseFloat("10.33");     // returns 10.33
 
If the number cannot be converted, NaN (Not a Number) is returned.

http://www.w3schools.com/js/js_number_methods.asp

Using myNumber.MAX_VALUE, where myNumber is a variable, expression, or value, will return undefined:

var x = 6;
var y = x.MAX_VALUE;    // y becomes undefined

No comments:

Post a Comment