#### After Effects Expressions & JavaScript

operators

JavaScript operators are symbols used to execute arithmetic operations, comparisons, assign values, determine the logic between variables (boolean), and other tasks.

Arithmetic operators

`R=5+2; //R returns 7`

– (subtraction)

`R=5-2; //R returns 3`

* (multiplication)

`R=5*2; //R returns 10`

/ (division)

`R=5/2; //R returns 2.5`

% (returns remainder of division operation)

`R=5%2; //R returns 1 (5÷2=2 r 1)`

++ (increment by 1)

```R=5;
R=++R; //R returns 6```

– – (decrement by 1)

```R=5;
R=--R; //R returns 4```

Assignments operators

Where R=5 and S=2

= (assigns value)

`R=S; //R is assigned the value of S, R returns 2`

+=

`R+=S; //Short cut for R=R+S, R is assigned 5+2, R returns 7`

-= (see example)

`R-=S; //Short cut for R=R-S, R is assigned 5-2, R returns 3`

*= (see example)

`R*=S; //Short cut for R=R*S, R is assigned 5*2, R returns 10`

/= (see example)

`R/=S; //Short cut for R=R/S, R is assigned 5/2, R returns 2.5`

%= (see example)

`R%=S; //Short cut for R=R%S, R is assigned 5%2, R returns 1 (5÷2=2 r 1)`

String operators

Where A=”Hello “, B=”World”

+ (join strings)

`C=A+B; //C returns "Hello World"`

+= (see example)

`A+=B; //Short cut for A=A+B, A returns "Hello World"`

Comparison operators

Where R=5

== (is equal to)

`R==5; //true`
`R==10 //false`

=== (equal to and same type)

`R===10; //false`
`R===5; //true`
`R==="5" //false`

!= (not equal)

`R!=5; //false`
`R!=10; //true`

!== (not equal or not same type)

`R!==10; //true`
`R!==5; //false`
`R!=="5"; //true`

> (greater than)

`R>5; //false`

< (less than)

`R<5; //false`

>= (greater than or equal)

`R>=5; //true`

<= (less than or equal)

`R<=5; //true`

Ternary (3 part) conditional operator

```R=10;
T=(R&gt;50)?100:25;
T
//When R &gt; 50 T returns 100, When R &lt;= 50, which it is, T returns 25```

Logical operators

Where R=5 and Y=20

&& (and)

`(R>4 && R<14); //true`
`(Y>4 && Y<14); //false`

|| (or)

`(R>4 || R>25); //true`
`(Y<4 || Y>25); //false`

! (not)

`(!R>4); //false`
`(!Y<4); //true`