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. Spread operator "..." works for arrays, but not objects.
Forum Update on Monday, May 27th 2025

Spread operator "..." works for arrays, but not objects.

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 2 Posters 868 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.
  • T Offline
    T Offline
    Tannz0rz
    wrote on 15 Aug 2019, 19:25 last edited by
    #1

    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?

    1 Reply Last reply
    0
    • J Offline
      J Offline
      JKSH
      Moderators
      wrote on 15 Aug 2019, 21:56 last edited by JKSH
      #2

      Hi @Tannz0rz,

      QJSEngine supports ECMAScript 7 (2016): https://doc.qt.io/qt-5/qtqml-javascript-hostenvironment.html

      The 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

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      6

      1/2

      15 Aug 2019, 19:25

      • Login

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