有4种显示JavaScript输出的方法。
<html> <body> <p id="display"></p> <script> document.getElementById("display").innerHTML = 10 + 10; </script> </body> </html>
20.
<html> <body> <script> document.write(2 + 3); </script> </body> </html>
5
<html> <body> <script> console.log(2 + 3); </script> </body> </html>
5.
<html> <body> <script> alert(2 + 3); </script> </body> </html>
5
在处理json字符串或其他大数据console.log的情况下,log是最佳选择。