title: Is it possible to create custom operators in JavaScript?
body: <p>During the Math classes we learned how to define new operators. For example:</p>
  
  <h2><code>(ℝ, ∘), x ∘ y = x + 2y</code></h2>
  
  <p>This defines <code>∘</code> law. For any real numbers <em>x</em> and <em>y</em>, <em>x ∘ y</em> is <em>x + 2y</em>.</p>
  
  <p>Example: <code>2 ∘ 2 = 2 + 4 = 6</code>.</p>
  
  <hr>
  
  <p>Is possible to define operators like this in JavaScript? I know that a function would do the job:</p>
  
  <pre><code>function foo (x, y) { return x + 2 * y; }
  </code></pre>
  
  <p>but I would like to have the following syntax:</p>
  
  <pre><code>var y = 2 ∘ 2; // returns 6
  </code></pre>
  
  <p>instead of this:</p>
  
  <pre><code>var y = foo(2, 2);
  </code></pre>
  
  <p>Which is the closest solution to this question?</p>