The answer to the question Is it possible to create custom operators in JavaScript? is not yet, but @Benjamin suggested that it would be possible to add a new operator using third party tools:
It is possible to use third party tools like sweet.js to add custom operators though that'd require an extra compilation step.
I will take the same example, like in the previous question:
(ℝ, ∘), x ∘ y = x + 2y
For any two real numbers x and y: x ∘ y is x + 2y that is also a real number. How can I add this operator in my extended JavaScript language?
After the following code will be run:
var x = 2
, y = 3
, z = x ∘ y;
console.log(z);
The output will contain
8
(because 8 is 2 + 2 * 3)
How would I extend the JavaScript language to support a new operator?