Not sure how better to word this (and, consequently, couldn't find previous answers, though I expect this has been answered before), but I'm interested in whether there's a way to turn code like this:
if ( this.props.mailboxFilter == 'sent' ) {
return this.currentUser.canActOnBehalfOf( m.senderID );
} else {
return !this.currentUser.canActOnBehalfOf( m.senderID );
}
To something like the below (not sure how better to express it):
var bangOrNot = this.props.mailboxFilter == 'sent ? '!' : '';
bangOrNot( this.currentUser.canActOnBehalfOf( m.senderID ) );
As in, is there a way to avoid the extended if/else syntax and all the repetition by choosing whether or not to call the return
line with a bang?