11

I am trying to understand what is possible with binary operators (only binary operators) in JavaScript. So far the list of binary operators I have discovered are the the following. They are primarily sourced from this list, but are any missing?

Note, I am after specifically only binary operators which, according to the source listed above, is defined as binary operators you use with two objects (is this accurate?). I have also added the additions from @zessx.

+   //Add
-   //Subtract
/   //Divided by
*   //Multiple
%   //Modulus
<   //Less than
>   //Greater than
&   //AND
|   //OR
^   //XOR
~   //Invert each bits
<<  //Move all bits onto the left
>>  //Move all bits onto the right
>>> //Move all bits onto the right and fill left end with 0
7
  • there are also binary operator for bit, like '|' (or) and '&' for and. Commented Aug 25, 2012 at 13:19
  • 1
    first result on google: web.eecs.umich.edu/~bartlett/jsops.html Commented Aug 25, 2012 at 13:19
  • this seems to be a video guide of all operators: bateru.com/news/2011/03/… Commented Aug 25, 2012 at 13:21
  • This seems like a good link to me. bit.ly/SApOip Commented Aug 25, 2012 at 13:26
  • 1
    Really not sure why this is getting down voted. I am sure it is for a good reason, but I am really not sure why. Commented Aug 25, 2012 at 13:44

3 Answers 3

15

You will find a complete list in the specification, in the expression chapter. Because the most "normal" operators are binary (see the definition at Wikipedia), they are not explicitly listed as such (like the unary and ternary operators). They are:

  • Multiplicative Operators
    • The * Operator
    • The / Operator
    • The % Operator
  • Additive Operators
    • The Addition operator (+)
    • The Subtraction Operator (-)
  • Bitwise Shift Operators
    • The Left Shift Operator (<<)
    • The Signed Right Shift Operator (>>)
    • The Unsigned Right Shift Operator (>>>)
  • Relational Operators
    • The Less-than Operator (<)
    • The Greater-than Operator (>)
    • The Less-than-or-equal Operator (<=)
    • The Greater-than-or-equal Operator (>=)
    • The instanceof operator
    • The in operator
  • Equality Operators
    • The Equals Operator (==)
    • The Does-not-equals Operator (!=)
    • The Strict Equals Operator (===)
    • The Strict Does-not-equal Operator (!==)
  • Binary Bitwise Operators (&, ^, |)
  • Binary Logical Operators (&&, ||)

Technically speaking, also the assignment and comma operators are binary.

Sign up to request clarification or add additional context in comments.

Comments

11

There are the following arithmetic operators supported by the JavaScript language.

Assume variable A holds 10 and variable B holds 20 then:

Enter image description here

Enter image description here

Enter image description here

Enter image description here

Enter image description here

Enter image description here

Here is the original page link.

3 Comments

The conditional expression (also called "the ternary operator") is not a binary operator.
@Bergi The question was modified after this post. Originally it was talking about all operators.
OK, but then you forgot all those unary operators like ! or new
1
+   //Add
-   //Subtract
/   //Divided By
*   //Multiple
%   //Modulus
<   //Less than
>   //Greater than
!   //Not
&   //And
|   //Or
^   //Xor
~   //Invert each bits
<<  //Move all bits onto the left
>>  //Move all bits onto the right
>>> //Move all bits onto the right and fill left end with 0

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.