javascript semantics

javascript

Solution

`a ? b : c` means "`b` if `a` is true, `c` otherwise".

`-a` means `a`, negated.

`a -= b` and `a += b` mean `a = a - b` and `a = a + b` respectively. However, in your example these operators aren't actually present in the code, they are just text strings the code is manipulating.

Problem

I am trying upgrade my javascript programming skills ( or lets say my programming skills period : ) ) so I am trying to understand some semantics : in the first line what does the "?" mean as well as the minus sign in "-distance" in the second line what does '+=' or '-=" mean? ``` el.css(ref, motion == 'pos' ? -distance : distance) animation[ref] = (mode == 'show' ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance; ``` thank you

Original source