Bio Hazard Bio Hazard - 1 year ago 103
Javascript Question

JavaScript weird assignment code

I found this line of code in a project and I couldn't under

return d.isPointInside(a, b) ? (console.log("runned"), c = !0, !1) : void 0

And I couldn't understand the part:

(console.log("runned"), c = !0, !1)

The word "runned" should be displayed in the browser's console, But need some help to understand the rest.

Answer Source

Just some type juggeling

!0 === true
!1 === false
void 0 === undefined

The result with some longer words:

(console.log("runned"), c = true, false);

The complete return statement reads as following, without use of the Comma Operator:

if (d.isPointInside(a, b)) {
    c = true;
    return false;
} else {
    return undefined;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download