I recently came across this variable initialization in a WebGL tutorial:
var mouse = { x: 0, y: 0 }, INTERSECTED;
I've never seen this format. I understand it's creating an object with an x and y property, but how is INTERSECTED related to the variable/object?
Thanks!
The line is simply declaring two variables (mouse
and INTERSECTED
), and initializing mouse
to { x: 0, y: 0}
.
INTERSECTED
is not necessarily related to mouse
, though clear code should only declare multiple variables together if they are highly related (even then, many prefer to declare every variable on a separate line).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With