JavaScript使用Max函数返回两个数字中较大数的代码。

JavaScript的Math对象带有一个max函数用于获取两个数字的较大数代码:


 <p id="demo"> Click the button to return the highest number of 5 and 10. </p> <button it</button> <script> function myFunction() { document.getElementById("demo").innerHTML=Math.max(5,10); } </script>


返回输出:10

codego.net代码节选