Converts the string to a float value - Node.js String

Node.js examples for String:Parse

Description

Converts the string to a float value

Demo Code


/**/*from  w  w  w. j  av  a2s .  c  o m*/
 * converts the string to a float value
 * @param boolean flat if the method should not use a flexible matching
 * @return Float or NaN
 */
toFloat: function(strict) {
  return parseFloat(strict === true ? this :
    this.replace(',', '.').replace(/(\d)-(\d)/, '$1.$2'));
}

Related Tutorials