我想了解Javascript中的單行代碼,但它不是很明顯。在更易讀的代碼中轉換javascript一行
this._iconNeedsUpdate = !0,this._expandBounds(t), t instanceof L.MarkerCluster ? (e || (this._childClusters.push(t), t.__parent = this), this._childCount += t._childCount) : (e || this._markers.push(t), this._childCount++), this.__parent && this.__parent._addChild(t, !0)
我試着用下面的代碼轉換,但它不工作:
this._iconNeedsUpdate = !0;
this._expandBounds(t);
if (t instanceof L.MarkerCluster) {
if (!e) {
this._childClusters.push(t);
t.__parent = this;
} else {
this._childCount += t._childCount;
}
} else {
if (!e) {
this._markers.push(t);
this._childCount++;
}
}
if (this.__parent) {
this.__parent._addChild(t, !0);
}
任何想法
其中工程線路?
謝謝!
你的幫助後,良好的代碼是:
this._iconNeedsUpdate = true;
this._expandBounds(t);
if (t instanceof L.MarkerCluster) {
if (!e) {
this._childClusters.push(t);
t.__parent = this;
}
this._childCount += t._childCount
} else {
if (!e) {
this._markers.push(t);
}
this._childCount++;
}
if (this.__parent) {
this.__parent._addChild(t, true);
}
謝謝!
我在前三行代碼展開的計算6個不同的JavaScript概念。究竟是什麼,你不明白嗎? – Quentin
這個問題上的[加密]標籤讓我發笑。 –
所以縮小版本可以工作,但擴展版本不能?這是問題嗎? (請說明問題) – SparK