QML - Javascript: Does Javascript support EcmaScript 6?
-
wrote on 1 Jun 2017, 22:34 last edited by Ibrahim 6 Jan 2017, 22:37
Hi; I think Javascript for QML doesn't support ES6 (EcmaScript 6). Well, Is there any way for EcmaScript6 features? Thanks.
-
wrote on 2 Jun 2017, 02:56 last edited by
http://doc.qt.io/qt-5/qtqml-javascript-functionlist.html has some functions commented with
// ECMAScript 6:
Was there something specific?
-
http://doc.qt.io/qt-5/qtqml-javascript-functionlist.html has some functions commented with
// ECMAScript 6:
Was there something specific?
wrote on 2 Jun 2017, 11:04 last edited by@6thC thanks. I want to use arrow functions, default parameter values, rest parameters and spread operator. Are they possible?
-
@6thC thanks. I want to use arrow functions, default parameter values, rest parameters and spread operator. Are they possible?
wrote on 2 Jun 2017, 11:53 last edited by@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.
-
wrote on 14 Aug 2017, 06:52 last edited by
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:
-
wrote on 17 Dec 2018, 06:40 last edited by JKSH
Check this one... [EDIT: Non-Qt link removed --JKSH]
-
And for a noteworthy update: Qt 5.12 now supports ES6.
-
wrote on 8 Mar 2019, 20:09 last edited by
@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
-
@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
wrote on 8 Mar 2019, 21:36 last edited by@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.