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.
Qt 6.11 is out! See what's new in the release blog

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

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 2 Posters 1.3k Views 1 Watching
  • 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 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
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on 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

      • Login

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