Replace() yields “Uncaught TypeError: undefined is not a function” when used with zero


I'm using the following code to parse 'Balance' of the type 'number' in the DB

function Query_Member_points_credits_summaryExecute() 
var Balance ="$['Balance']");
var balance = parseFloat(Balance.replace(',', '').replace(' ', ''));
console.log("balance " + balance);
var threshold = parseFloat(50000);
console.log("threshold " + threshold);

Whenever Balance = any value other than zero, the alert shows (string) and the function works fine (replace() method works fine).
However, when Balance = 0, the alerts shows (number) and I get the error in the title.

If the value in the DB of the type 'Number', why it is changing automatically to 'string' for all values and remain 'number' for zero only?

This made me assume all numbers are converted automatically to string at the frontend, until I found this bug that causes the App to hang when the Balance = 0.
1 person has
this question