重複の可能性:
JavaScript でのプロパティの存在の確認
i.e. this.tBodies[0].rows[0].cells
jQuery を使用せずに、テーブルの tbody セル ( ) の最初の行を取得しようとしています。何もない場合は、エラーを発生させたくありません。以下はうまくいくようですが、もっと良い方法はありますか?
var tbody_cells = (this.tBodies
&& this.tBodies
&& this.tBodies[0].rows
&& this.tBodies[0].rows[0])
? this.tBodies[0].rows[0].cells
:undefined;