I think the 2 sets of brackets makes it a bit confusing but I saw another usage in googles example, they used something similar, I hope this will help you understand better:
var app = window.app || (window.app = {});
console.log(app);
console.log(window.app);
so if windows.app
is not defined, then window.app = {}
is immediately executed, so window.app
is assigned with {}
during the condition evaluation, so the result is both app
and window.app
now become {}
, so console output is:
Object {}
Object {}