Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-36875

ES6: Support "for...of"

    XMLWordPrintable

    Details

    • Commits:
      128485ccdb4f1c6f1bf1ebea85c5bed749cacd7a e3b9726483cb7336aa54ae7d9455becbd148b2b6

      Description

      Hi,

      simply copy/pasting an example from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of

      let arr = [ 3, 5, 7 ];
      arr.foo = "hello";
      
      for (let i in arr) {
         console.log(i); // logs "0", "1", "2", "foo"
      }
      
      for (let i of arr) {
         console.log(i); // logs "3", "5", "7"
      }
      

      for...in puts the key in the variable you define in the for statement.
      for...of puts the value in the variable you define in the for statement.

      Having support for that would simplify some loops. Not greatly and easy to "workaround" but it would still be nice to have.

        Attachments

          Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            Activity

              People

              Assignee:
              laknoll Lars Knoll
              Reporter:
              markg85 Mark
              Votes:
              5 Vote for this issue
              Watchers:
              11 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes