operators Flashcards
Modulus
% Modulus (division remainder)
x = y % 2 y = 5 x = 1
Modulus
% Modulus (division remainder)
x = y % 2 y = 5 x = 1
increment
++ Increment
x = ++y y = 6 x = 6
decrement
– Decrement
x = –y y = 4 x = 4
=
x = y x = y
+=
x += y x = x + y
-=
x -= y x = x - y
*=
x *= y x = x * y
/=
x /= y x = x / y
%=
x %= y x = x % y
string operator
+
text3 = text1 + text2
text 1: Good
text 2: Morning
text 3: Good Morning
string operator
+=
text1 += text2
text1 (before) : good
text2 : Morning
text1 (after): Good Morning
==
equal to
===
equal value and equal type
!=
not equal
!==
not equal value or not equal type
>
greater than
less than
> =
greater than or equal to
<=
less than or equal to
Conditional (Ternary) Operator
variablename = (condition) ? value1:value2
voteable = (age < 18) ? “Too young”:”Old enough”;
&&
and
||
or
!
not
increment
++ Increment
x = ++y y = 6 x = 6
decrement
– Decrement
x = –y y = 4 x = 4
=
x = y x = y
+=
x += y x = x + y
-=
x -= y x = x - y
*=
x *= y x = x * y
/=
x /= y x = x / y
%=
x %= y x = x % y
string operator
+
text3 = text1 + text2
text 1: Good
text 2: Morning
text 3: Good Morning
string operator
+=
text1 += text2
text1 (before) : good
text2 : Morning
text1 (after): Good Morning
==
equal to
===
equal value and equal type
!=
not equal
!==
not equal value or not equal type
>
greater than
less than
> =
greater than or equal to
<=
less than or equal to
Conditional (Ternary) Operator
variablename = (condition) ? value1:value2
voteable = (age < 18) ? “Too young”:”Old enough”;
&&
and
||
or
!
not