<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>JS代码实例</title> </head> <body> <h3>JavaScript代码实例</h3> <table border="1"> <tr> <th>功能描述</th> <th>代码示例</th> </tr> <tr> <td>输出文本到控制台</td> <td> <pre><code>console.log("Hello, World!");</code></pre> </td> </tr> <tr> <td>定义变量并赋值</td> <td> <pre><code>let x = 10;</code></pre> </td> </tr> <tr> <td>条件判断语句</td> <td> <pre><code>if (x > 5) { console.log("x is greater than 5"); } else { console.log("x is less than or equal to 5"); }</code></pre> </td> </tr> <tr> <td>循环语句</td> <td> <pre><code>for (let i = 0; i < 5; i++) { console.log(i); }</code></pre> </td> </tr> <tr> <td>函数定义与调用</td> <td> <pre><code>function greet(name) { console.log("Hello, " + name + "!"); } greet("Alice");</code></pre> </td> </tr> </table> </body> </html>
(图片来源网络,侵删)
本文来源于互联网,如若侵权,请联系管理员删除,本文链接:https://www.9969.net/62244.html