I am studying Javascript. Can someone please tell me what I'm not doing right?
total = pdf_tp_summa+2490+(Number(elem_summa_sms.value))+(Number(elem_summa_push.value));
typeof(pdf_tp_summa) = number typeof(elem_summa_sms.value) = string typeof(elem_summa_push.value) = string
The result is NaN. It is how javascript works.
//elem_summa_push.value is string, so
Number(elem_summa_push.value)//eg. Number('asdf')
Would result in NaN.
And when you add any number to the NaN it would result NaN.
If the elem_summa_push.value
is type of string but still contains number then it wouldn't result in NaN. For eg. Number('234')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.