執行 ❯
建立您
自己的
網站
×
更改方向
儲存程式碼
更改主題,深色/淺色
前往 Spaces
<!DOCTYPE html> <html> <body> <h1>The Console Object</h1> <h2>The time() Method</h2> <p>Remember to open the console (Press F12) before you click "Run".</p> <p>Test to see which loop is the fastest.</p> <script> console.time("for loop"); for (let i = 0; i < 1000000; i++) { } console.timeEnd("for loop"); let i = 0; console.time("while loop"); while (i < 1000000) { i++; } console.timeEnd("while loop"); </script> </body> </html>