Java Reference

In-Depth Information

Incrementing Values

If you only want to increment a value by
1
, you can use the
++
operator. This goes either

directly before or after the variable.

So what's the difference between putting the
++
operator before or after the variable? The

main difference is the value that is returned by the operation. Both operations increase the

value of the
points
variable by
1
, but
points++
will return the original value
then
in-

crease it by 1, whereas
++points
will increase the value by 1, then return the new value:

points++; // will return 3, then increase points to 4

<< 3

++points; // will increase points to 5, then return it

<< 5

There is also a
--
operator that works in the same way:

points--;

<< 5

--points;

<< 3

Infinity

Infinity
is a special error value in JavaScript that is used to represent any number that

is too big for JavaScript to deal with. The biggest number that JavaScript can handle is

1.7976931348623157e+308:

1e308; // 1 with 308 zeroes!

<< 1e308

2e308; // too big!

<< Infinity