test a string value to see if it represents a number - Node.js String

Node.js examples for String:String Value

Description

test a string value to see if it represents a number

Demo Code

/**//from w w w .ja  va 2  s. co m
 * isNumber - test a string value to see if it represents a number
 *
 * @return {Boolean} - true or false
 */
String.prototype.isNumber = function () {
    'use strict';
    return !isNaN(parseFloat(this)) && isFinite(this);
};

Related Tutorials