Spread operator "..." works for arrays, but not objects.
Solved
QML and Qt Quick
-
wrote on 15 Aug 2019, 19:25 last edited by
A very simple JS example:
// Works var arr_1 = [ 3 ]; var arr_2 = [ 1, 2, ...arr_1 ]; // Does not work var obj_1 = { "C": 3 }; var obj_2 = { "A": 1, "B": 2, ...obj_1 };
This is built with Qt 5.12.4 (MSVC 2017 x64). Can anyone else confirm this?
-
Hi @Tannz0rz,
QJSEngine
supports ECMAScript 7 (2016): https://doc.qt.io/qt-5/qtqml-javascript-hostenvironment.htmlThe spread syntax was added to objects in ECMAScript 9 (2018) and is also considered "experimental": https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax
1/2