If I have a variable that is given a “numeric” value from a PHP echo…
var names_each = <?php echo $ind_name_each; ?>;
…and $ind_name_each is derived from a MySQL column of type decimal(5,2),
is it a number or a string in JavaScript?
if all_total = 6.00
and names_each = 5.00
and I do this:
all_total = parseInt(names_each) + all_total;
I get 56.00
all_total = names_each + all_total;
I get 5.006.00
all_total = parseFloat(names_each) + all_total;
I get 56.00
I need some understanding here.
Both variables are strings:
so the + operation concatenates those strings:
but if you parse them to numbers first, then you can use + to add them: