> For the complete documentation index, see [llms.txt](https://mistborn.gitbook.io/til-coding/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mistborn.gitbook.io/til-coding/javascript/code-structure.md).

# Code structure

## Statements

Statements 代表執行動作的語法， 通常會分行寫提高可讀性。

```javascript
alert('Hello');
alert('World');
```

## semicolons

當有斷行時分號可能會被省略，JavaScript 會自動加上分號，但並不是所有狀況都會自行加上分號，像是以下的範例就會出現問題。

```javascript
alert("There will be an error")

[1, 2].forEach(alert)
```

因為沒有分號，JavaScript 引擎會視為一整行的 code 因此會出現錯誤。

```javascript
alert("There will be an error")[1, 2].forEach(alert)
```

## Comments

單行註解用 // 熱鍵 **Ctrl+/**\
多行註解用 /\*...\*/ 熱鍵 **Ctrl+Shift+/**

巢狀的註解會出現錯誤

```javascript
/*
  /* nested comment ?!? */
*/
alert( 'World' );
```
