I'm learning js and I've come across an example in which || is used when declaring a var as a function:
var Triangulation = Triangulation || (function() {
...
It seems to me that this is checking to see if the var has already been declared before assigning it. Looking around the web, I don't see any other examples where this approach is used. What would be a reason to take this approach vs:
var Triangulation = function() {
...
Thanks
var Triangulation = Triangulation || (function() {
just implies that ifTrianglulation
is declared before coming to this step then skip the step. else carry on executing the code inside function{} .