エントリーの編集
エントリーの編集は全ユーザーに共通の機能です。
必ずガイドラインを一読の上ご利用ください。
- バナー広告なし
- ミュート機能あり
- ダークモード搭載
関連記事
オブジェクトがnullやundefindでないか評価する。 - うなの日記
ifで評価すれば一発で判定できます。 if ( !target ) { ... } // 以下のようにはしなくてもいい。 // if... ifで評価すれば一発で判定できます。 if ( !target ) { ... } // 以下のようにはしなくてもいい。 // if ( target == null || target == undefined ) { ... } 値ごとのifでの評価結果は次の表の通り。空文字列や0はfalse扱いなので注意。 値 ifで評価した結果 Object true undefined false null false 0 false 1 true -1 true ""(空文字列) false "a" true 配列 true ハッシュ true 確認してみます。 var stdout = document.getElementById("stdout"); // オブジェクト / null, undefind は false stdout.innerHTML += "null is " + (
2012/11/09 リンク