[javascript] How to convert a currency string to a double with jQuery or Javascript?

// "10.000.500,61 TL" price_to_number => 10000500.61

// "10000500.62" number_to_price => 10.000.500,62

JS FIDDLE: https://jsfiddle.net/Limitlessisa/oxhgd32c/

var price="10.000.500,61 TL";
document.getElementById("demo1").innerHTML = price_to_number(price);

var numberPrice="10000500.62";
document.getElementById("demo2").innerHTML = number_to_price(numberPrice);

function price_to_number(v){
    if(!v){return 0;}
    v=v.split('.').join('');
    v=v.split(',').join('.');
    return Number(v.replace(/[^0-9.]/g, ""));
}

function number_to_price(v){
    if(v==0){return '0,00';}
    v=parseFloat(v);
    v=v.toFixed(2).replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");
    v=v.split('.').join('*').split(',').join('.').split('*').join(',');
    return v;
}