3 ms·
JavaScript method call notation is arguably a ternary operator, or a candidate for the "Near Misses" list (because « foo.bar(x) » isn't the same as « var meth =
by mjw1007 2y ago
JavaScript method call notation is arguably a ternary operator, or a candidate for the "Near Misses" list (because « foo.bar(x) » isn't the same as « var meth = foo.bar; meth(x) »).
- marcosdumay 2y agoJavascript's `this` is the gift that keeps giving...
- sltkr 2y agoNot technically ternary because the number of arguments is variable, but definitely an interesting case. `a.b(c)` is actually a bit of a degenerate case because `b` must be an identifier, it cannot be an arbitrary expression, which seems to disqualify it as a true operator. But actually `a.b` is just syntactic sugar for `a["b"]` and you can view []() as an operator, so you can write nonsense like: [function(){return this[1]}, 42][0]() {foo(a){return this.x*a; }, bar(a){return this.y*a;}, x: 1, y:2} [ Math.random() < 0.5 ? 'foo' : 'bar' ] (100 + 20 + 3)