I’m investigating Three.js at the moment and have come across this variable declaration at the top of the main source file:
var THREE = THREE || { REVISION: '52' };
I’m just wondering what the OR (||) is doing in there – what is the function of it?
The above means:
If the value of
THREEevaluates totrue, assign the value ofTHREEto theTHREEvariable, otherwise initialize it to the object{ REVISION: '52' }.