Javascript examples for Math:max
Math.max and Math.min NaN on undefined entry
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=( function() {//www . j a va2s . co m var a = 5; var b = 10; var c = undefined; var defaultForMax = function (num) { return typeof num === 'number' ? num : -Infinity; }; c = defaultForMax(c); // -Infinity console.log(c); console.log(Math.max(a, b, c)); // 10 }); </script> </head> <body> </body> </html>