Reputation: 1189
var p = this.getParams();
var pD = (o.params||{});
if (this.useJsonData) pD = (pD.jsonData||{});
this.cursor = (pD && pD[p.start]) ? pD[p.start] : 0;
And what is the difference between these two lines.
this.cursor = pD[p.start] || this.cursor || 0;
Is the first code fine or there is any fault in it.
Upvotes: -1
Views: 72
Reputation: 2920
Look at this page: https://developer.mozilla.org/en/JavaScript/Guide/Expressions_and_Operators
Search for conditional operator
, logical operators
and short-circuit evaluation
.
Upvotes: -1
Reputation: 230531
Your second line has a fault. What if pD is null? Also it will keep value of this.cursor that is true (not null or false, that is).
Otherwise, they are identical.
Upvotes: 0