1. Major Operators

Operator Description Comment
/* */

//

encloses multi-line comment

indicates rest of line is a comment

 
= assignment  
; terminates a line (optional) x = 1 or x = 1; are both acceptable in JavaScript

Note: semi-colons can be used to separate more than one statement on a line but this style of coding is inadvisable.

== checks for equality, e.g.

if (x==1)

if you use single = when trying to check for equality:

if(j=5) {statement}

then the expression evaluates to true and the expression is also executed (j is assigned 5). This is comparable to bug-prone ‘C’ behaviour

!=

> >=

< <=

checks for inequality

greater than, gr. than or equal

less than, less than or equal

 
! NOT (negates a boolean expression)  
+= -= *= shorthand operator to add/subtract/multiple two numbers and assign to first x += s (is like x = x + s, doing addition or string concat. depending on whether these are numbers or strings)
++ -- quick increment (decrement) x++ is like x = x + 1
&&

||

Logical and,

Logical or respectively.

(a && b) if a is false, b is not evaluated (or executed)

(a || b) if a is true, b is not evaluated (or executed)

a ? b : c Conditional operator if boolean expr. "a" is true, use expr. "b", otherwise use expr. "c"