javascript - How do I Convert NaN to a 0? -


when value not entered in 1 of forms, creates later result of nan in javascript. want declare anytime nan show instead show 0. thought adding

<script>  = || 0  </script> 

to beginning of scripts fine.

is there anyway nan equal 0, no matter situation?

nan global object cannot override.

reference: https://developer.mozilla.org/en-us/docs/javascript/reference/global_objects/nan

one alternative use isnan then

a = isnan(a) ? 0 : a; 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -