0

Can someone tell me the meaning of the expression (x = +_, force)? I know that x is getting incremented by _ but what does force separated by comma does?

  force.x = function(_) {
    return arguments.length ? (x = +_, force) : x;
  }

is it calling/referencing the function named force? in the full code force is a function..

mx_code
  • 1,777
  • 3
  • 10

1 Answers1

3

The expression

(x = +_, force)

features the comma operator and return the last expression force. In this case as result for assigning.

A better style would be

force.x = function(_) {
    if (arguments.length) {
        x = +_;
        return force;
    } else {
        return x;
    }
}
Nina Scholz
  • 323,592
  • 20
  • 270
  • 324