Loading ...
Sorry, an error occurred while loading the content.

3121Re: [jslint] Just got confused with the `?` operator

Expand Messages
  • george_weilenmann
    Feb 5, 2013
    • 0 Attachment
      This is more of an error on the part of the knowledge of the developer
      then on the part of JSLint. The code pattern is perfectly valid and not
      confusing to someone who has a good grasp on operator precedence.
      even if JSLint was to require () around the ternary operator and
      results.
      Such that your line
      for (i = 0; i < isOneWayFlight ? 1 : 2; i += 1) {
      would have thrown an error for missing () around ternary.You still could
      have done
      for (i = 0; (i < isOneWayFlight ? 1 : 2); i += 1) {
      and the same error would have occurred in your logic.
      See http://www.javascriptkit.com/jsref/precedence_operators.shtml for a
      nice table on precedence of operators.


      --- In jslint_com@yahoogroups.com, "Felix E. Klee" wrote:
      >
      > On Tue, Feb 5, 2013 at 6:30 PM, Keradus wrote:
      > > It's a matter of priority.
      >
      > I know. Still the error slipped in, out of sloppiness, like many
      errors
      > that JSLint is designed to capture.
      >



      [Non-text portions of this message have been removed]
    • Show all 8 messages in this topic