I came across the following line of code in the underscore.js source:
function (obj, iterator, context) {
iterator || (iterator = _.identity);
...
}
Is that syntax equivalent to:
if (!iterator) {
iterator = _.identity;
}
Are there any performance benefits to using the former syntax other than reducing the statement to one line?
Yes, it is functionally equivalent to that.
The only benefit to doing it this way is that your check takes up two less lines.