Re: Splitting a conditional operator (?:) across multiple lines
- --- In firstname.lastname@example.org, "enaeseth" <enaeseth@...> wrote:
>Check the documentation page. JSLint recommends breaking lines after
> I'm trying to edit an existing codebase to make it pass JSLint
> verification so that it can be packed or minified safely. Mostly, my
> code requires small, obvious changes, but JSLint balks at my common
> practice of splitting long statements that use the conditional (ternary)
> operator across three lines, like so:
> this.foo = (typeof(foo) != "undefined") ? foo : true;
> What is a safe and acceptable way to write these statements? Some of
> them are short enough to be written on one line, but most are not.
operators to avoid semicolon insertion mishaps.
this.foo = typeof(foo) !== "undefined" ?