Ok, let's assume that this.grid.getStore().sum('fees')
returns something, let's say "okay!".
now the return statement in your code is a convoluted way of saying :
if(this.grid)//this.grid is defined and doesn't evaluate as 'false'
return this.grid.getStore().sum('fees');
else
return this.grid;
if this hasn't got a grid, we return undefined, else we call gridStore...
and return its own return.
It is a common way of avoiding "undefined has no method 'gridStore'"
the VERY important part is that, in a && f()
, f() will NOT be called if 'a' evaluates to false. there are many things that evaluate to false, such as any undefined variable, null
, empty strings... (note that strings that contain falsy things like "false"
or "0000"
are actually truthy). or even unreadable babble like function(){return null;}();
may evaluate as false.