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
, strings that contain falsy things like "false" or "0000"
or even unreadable babble like function(){return null;}();
a
is notundefined
andb
is notundefined
, returnb
. – The New Idiot Jun 25 at 7:49if (this.grid) { return this.grid.getStore().sum('fees');}
– openorclose Jun 25 at 7:55