Parsing numbers with a comma decimal separator in JavaScript

I believe the best way of doing this is simply using the toLocaleString method. For instance, I live in Brazil, here we have comma as decimal separator. Then I can do:

var number = 10.01;
console.log(number)
// log: 10.01

console.log(number.toLocaleString("pt-BR"));
// log: 10,01


var number = parseFloat(obj.value.replace(",",""));

You'll probably also want this to go the other way...

obj.value = number.toLocaleString('en-US', {minimumFractionDigits: 2});

You need to replace (remove) the dots first in the thousands separator, then take care of the decimal:

function isNumber(n) {
    'use strict';
    n = n.replace(/\./g, '').replace(',', '.');
    return !isNaN(parseFloat(n)) && isFinite(n);
}