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

3123Re: Just got confused with the `?` operator

Expand Messages
  • douglascrockford
    Feb 5, 2013
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, "Felix E. Klee" wrote:
      > /*jslint devel: true */
      >
      > (function () {
      > 'use strict';
      >
      > var isOneWayFlight = true, i;
      >
      > for (i = 0; i < isOneWayFlight ? 1 : 2; i += 1) {
      > console.log(i);
      > }
      > }());
      >
      > Instead, the runtime enters an infinite loop. It outputs: 0, 1, 2, ...
      >
      > Correct version of the for statement, doing what I want:
      >
      > for (i = 0; i < (isOneWayFlight ? 1 : 2); i += 1) {
      > console.log(i);
      > }


      Thanks. Please try it now.
    • Show all 8 messages in this topic