What do javascript comma separated functions mean

I am reading a dojo javscript library and I see many complex functions that I cannot understand. For instance:

_refreshUI: function () {
    this._hasUI && (g.empty(this.flowContainer), f.forEach(this.basemaps, function (a, b) { a.id || (a.id = "basemap_" + b); this.flowContainer.appendChild(this._buildNodeLayout(a))
}, this), g.create("br", { style: { clear: "both" } }, this.flowContainer), this._markSelected(this._selectedBasemap))

this function is written in one line. It contains functions separated by commas. Therefore, I cannot read it.

I do not ask what this function does.

What does it mean?:

this._hasUI && (firstFunction, secondFunction, ...)

What is he doing? Or how can I write it clearly?

+3
source share
1 answer

This is a way to perform only those functions if this._hasUItrue allows.

Try the following:

true && (console.log(1), console.log(2));

And this:

false && (console.log(1), console.log(2));

You will see that only the first line will run the functions console.log().

, (&&) . false, , true. , , .

+7

All Articles