Say something about undefined
- 主要言語
- JavaScript
- スター
- 148k
- フォーク
- 26.6k
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
I find people treat `undefined` incorrectly a lot. It's a value, you can use it, test for it, etc, but people frequently use `typeof x == "undefined"` when they don't need to.
I made a [fork](https://github.com/ianb/javascript) with a big changeset of my own opinions, but here's the section I wrote about undefined:
---
``````
## undefined
- `undefined` is an object. You should use it as an object. You can test for it. For instance:
```javascript
// good
function pow(a, b) {
if (b === undefined) {
b = 1;
}
return Math.pow(a, b);
}
// bad
function pow(a, b) {
if (typeof b == "undefined") {
b = 1;
}
return Math.pow(a, b);
}
```
- *Only* use `typeof x == "undefined"` when the variable (`x`) may not be declared, and it would be an error to test `x === undefined`:
```javascript
if (typeof Module == "undefined") {
Module = {};
}
// But also okay, for browser-only code:
if (window.Module === undefined) {
Module = {};
}
```
Note that you can't use `window` in Node.js; if you think your code could be used in a server context you should use the first form.
``````
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
まず issue の本文と、リンクされた fork にある undefined に関する提案セクションを確認してください。リポジトリのファイルもテストも指定されていません。undefined の確認についてプロジェクトが推奨する方針を確認し、maintainers が同意した場合は関連する style-guide ドキュメントを更新して、最終的な文言が周辺のガイダンスと一貫していることを確認してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript
- 領域
- documentation
- issue の種類
- ドキュメント
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 30/100