loading...

re: What do you think about the ternary operator? VIEW POST

TOP OF THREAD FULL DISCUSSION
re: I agree. I've seen it used in some perfectly legitimate ways such as in JSVerbalExpressions. startOfLine(enable = true) { this._pref...
 
// WHY NOT THIS?
startOfLine(enable = true) {
    this._prefixes = (enable && '^') || ''
    return this.add()
}

// OR EVEN THIS?
endOfLine(enable = true) {
    return(this._suffixes = (enable && '$') || '', this.add.bind(this))()
    //    ^ look mom, no space after `return`                          ^
    //                                                                 |
    //             note the artisanal external position of call parens |
}
Code of Conduct Report abuse