Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML - Javascript: Does Javascript support EcmaScript 6?
Forum Updated to NodeBB v4.3 + New Features

QML - Javascript: Does Javascript support EcmaScript 6?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qmljavascriptes6
9 Posts 7 Posters 11.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    Ibrahim
    wrote on 1 Jun 2017, 22:34 last edited by Ibrahim 6 Jan 2017, 22:37
    #1

    Hi; I think Javascript for QML doesn't support ES6 (EcmaScript 6). Well, Is there any way for EcmaScript6 features? Thanks.

    1 Reply Last reply
    0
    • 6 Offline
      6 Offline
      6thC
      wrote on 2 Jun 2017, 02:56 last edited by
      #2

      http://doc.qt.io/qt-5/qtqml-javascript-functionlist.html has some functions commented with

      // ECMAScript 6:
      

      Was there something specific?

      I 1 Reply Last reply 2 Jun 2017, 11:04
      2
      • 6 6thC
        2 Jun 2017, 02:56

        http://doc.qt.io/qt-5/qtqml-javascript-functionlist.html has some functions commented with

        // ECMAScript 6:
        

        Was there something specific?

        I Offline
        I Offline
        Ibrahim
        wrote on 2 Jun 2017, 11:04 last edited by
        #3

        @6thC thanks. I want to use arrow functions, default parameter values, rest parameters and spread operator. Are they possible?

        E 1 Reply Last reply 2 Jun 2017, 11:53
        0
        • I Ibrahim
          2 Jun 2017, 11:04

          @6thC thanks. I want to use arrow functions, default parameter values, rest parameters and spread operator. Are they possible?

          E Offline
          E Offline
          Eeli K
          wrote on 2 Jun 2017, 11:53 last edited by
          #4

          @Ibrahim Is it too difficult to test it yourself? Add for example to any item in qml (example taken from your link):

          Component.onCompleted: {
                          var params = [ "hello", true, 7 ];
                          var other = [ 1, 2, ...params ]; // [ 1, 2, "hello", true, 7 ]
          
                          var str = "foo";
                          var chars = [ ...str ]; // [ "f", "o", "o" ]
                      }
          

          and you will see if it works.

          1 Reply Last reply
          1
          • S Offline
            S Offline
            Stephen Quan
            wrote on 14 Aug 2017, 06:52 last edited by
            #5

            Arrow functions - not working:

            // SyntaxError: Unexpected token `>'
            var sq = (x => x * x);
            sq(2);
            

            Spread operator - not working.

            // SyntaxError: Unexpected token `;'
            var str = "foo";
            var chars = [ ...str ];
            

            Ongoing unresolved bug:

            https://bugreports.qt.io/browse/QTBUG-47735

            1 Reply Last reply
            0
            • I Offline
              I Offline
              iangregor
              wrote on 17 Dec 2018, 06:40 last edited by JKSH
              #6

              Check this one... [EDIT: Non-Qt link removed --JKSH]

              1 Reply Last reply
              0
              • G Offline
                G Offline
                GrecKo
                Qt Champions 2018
                wrote on 17 Dec 2018, 09:22 last edited by
                #7

                And for a noteworthy update: Qt 5.12 now supports ES6.

                S 1 Reply Last reply 8 Mar 2019, 20:09
                3
                • G GrecKo
                  17 Dec 2018, 09:22

                  And for a noteworthy update: Qt 5.12 now supports ES6.

                  S Offline
                  S Offline
                  sirhcybe
                  wrote on 8 Mar 2019, 20:09 last edited by
                  #8

                  @GrecKo Support seems limited. I can't get arrow functions to work: https://forum.qt.io/topic/100526/what-parts-of-ecmascript-7-are-supported-in-qt-5-12

                  S 1 Reply Last reply 8 Mar 2019, 21:36
                  0
                  • S sirhcybe
                    8 Mar 2019, 20:09

                    @GrecKo Support seems limited. I can't get arrow functions to work: https://forum.qt.io/topic/100526/what-parts-of-ecmascript-7-are-supported-in-qt-5-12

                    S Offline
                    S Offline
                    sirhcybe
                    wrote on 8 Mar 2019, 21:36 last edited by
                    #9

                    @GrecKo Never mind, I found your SO post explaining that I need to download the Qt Creator 4.9.0-beta2. That supports the new syntax.

                    1 Reply Last reply
                    1

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved