ravi
answered Nov 30 '-1 00:00
what happen if string multiply to number in JavaScript ?
in JavaScript number in string format behave like number . all math operation will work on it like number,
console.log("4"*0);//0
console.log("4"*5);//20
it means if number is define like string . still its number , lets test what is typeof "4" in JavaScript
console.log(typeof "4");//String
"number" is still string not number but behave like number
from above result we can conclude that string can multiply with number and give good result.than see below test:
console.log("how_do_you_know_i_am_no_number"*"10");//NaN
so "string" work like really string
so i think when we define string with value of number and try some math operation it check is it number if yes than do the operation as number either consider it as string.