Water Sunlight

軽量プログラミングの文法 - JavaScript/Python

ユーザ用ツール

サイト用ツール


js:object:basic

差分

このページの2つのバージョン間の差分を表示します。

この比較画面にリンクする

両方とも前のリビジョン 前のリビジョン
次のリビジョン
前のリビジョン
js:object:basic [2021/07/19 10:52]
y2sunlight [プロトタイプベースのオブジェクト指向]
js:object:basic [2021/07/19 10:58] (現在)
y2sunlight [静的プロパティと静的メソッド]
行 57: 行 57:
 </sxh> </sxh>
  
-=== メンバーの有無の判定 ===+=== メンバーの有無の判定(in演算子) === 
 + 
 +in演算子を使って、メンバーの存在の有無を判定することができます。
  
 <sxh javascript;title:Example> <sxh javascript;title:Example>
行 101: 行 103:
 console.log(taro.getSchoolName()); // NG (taro.getSchoolName is not a function) console.log(taro.getSchoolName()); // NG (taro.getSchoolName is not a function)
 </sxh> </sxh>
 +
 +=== メンバーの有無の判定(in演算子) ===
 +
 +in演算子を使って、メンバーの存在の有無を判定することができます。
 +
 +<sxh javascript;title:Example>
 +console.log('name' in taro);             // true
 +console.log('greeting' in taro);         // true
 +console.log('age' in taro);              // false
 +console.log('getSchoolName' in taro);    // false
 +
 +console.log('age' in Student);           // true
 +console.log('getSchoolName' in Student); // true
 +</sxh>
 +
 \\ \\
  
js/object/basic.1626659561.txt.gz · 最終更新: 2021/07/19 10:52 by y2sunlight