我想弄清楚爲什麼這個javascript函數返回0
當this.position.startOffset
值是0
但不是當值是0
以外的數字。爲什麼這個函數返回0
ready: function() {
return (this.position.startOffset
&& this.position.endOffset
&& this.position.representation.trim().length >= 0
&& this.text.id
&& this.user.id
&& this.concept);
}
看起來像它的評估布爾值,真或假,1或0 ...是,用意何在? – kvr
在JavaScript中,邏輯「和」運算符('&&')返回第一個虛假值。 0是虛假的,所以它會返回它。 – Ivar
你期望它返回什麼? – epascarello