Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. JavaScript version?
Forum Updated to NodeBB v4.3 + New Features

JavaScript version?

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 1.1k Views 2 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.
  • SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on last edited by
    #1

    How out of date is the implementation of JavaScript with Qt 5.15.2 ?

    Today I was working with a script and wanted to insert an item at the start of an array, the array already had content, there is a way of inserting an item into the front of the array using the unshift function. However this doesn't work as I've tried it today.

    Here is an example:

    var arySimon = [1,2,3,4];
    arySimon.unshift(99);
    

    Should result in arySimon containing:

    99,1,2,3,4
    

    Nothing is happening, unshift isn't doing anything. I'd just like to know for future reference which version of JavaScript is in use.

    KroMignonK 1 Reply Last reply
    -1
    • SPlattenS SPlatten

      How out of date is the implementation of JavaScript with Qt 5.15.2 ?

      Today I was working with a script and wanted to insert an item at the start of an array, the array already had content, there is a way of inserting an item into the front of the array using the unshift function. However this doesn't work as I've tried it today.

      Here is an example:

      var arySimon = [1,2,3,4];
      arySimon.unshift(99);
      

      Should result in arySimon containing:

      99,1,2,3,4
      

      Nothing is happening, unshift isn't doing anything. I'd just like to know for future reference which version of JavaScript is in use.

      KroMignonK Offline
      KroMignonK Offline
      KroMignon
      wrote on last edited by KroMignon
      #2

      @SPlatten said in JavaScript version?:

      How out of date is the implementation of JavaScript with Qt 5.15.2 ?

      You can find it out here:

      • https://doc.qt.io/qt-5/qtqml-javascript-hostenvironment.html
      • https://doc.qt.io/qt-5/qtqml-javascript-functionlist.html

      It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

      SPlattenS 1 Reply Last reply
      6
      • KroMignonK KroMignon

        @SPlatten said in JavaScript version?:

        How out of date is the implementation of JavaScript with Qt 5.15.2 ?

        You can find it out here:

        • https://doc.qt.io/qt-5/qtqml-javascript-hostenvironment.html
        • https://doc.qt.io/qt-5/qtqml-javascript-functionlist.html
        SPlattenS Offline
        SPlattenS Offline
        SPlatten
        wrote on last edited by
        #3

        @KroMignon , thank you

        KroMignonK 1 Reply Last reply
        0
        • J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by J.Hilk
          #4

          Matter of fact is, it was added in the 6th version of ECMA and Qml uses the 7th one

          So it should be part of the JS engine, and a quick test

              Component.onCompleted:{
                  var array1 = [1, 2, 3];
                  console.log(array1)
                  array1.unshift(5)
                  console.log(array1);
              }
          
          

          confirms with the output:

          qml: [1,2,3]
          qml: [5,1,2,3]
          

          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          1 Reply Last reply
          3
          • SPlattenS SPlatten

            @KroMignon , thank you

            KroMignonK Offline
            KroMignonK Offline
            KroMignon
            wrote on last edited by
            #5

            @SPlatten said in JavaScript version?:

            thank you

            Your welcome, by the way I just made a little test:

            var myList = [1, 2, 3, 4]
            console.log("List start: " + myList)
            myList.unshift(99)
            console.log("List unshifted: " + myList)
            

            Returns in console window (with Qt 5.12.10):

            List start: 1,2,3,4
            List unshifted: 99,1,2,3,4
            

            It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

            SPlattenS 1 Reply Last reply
            2
            • KroMignonK KroMignon

              @SPlatten said in JavaScript version?:

              thank you

              Your welcome, by the way I just made a little test:

              var myList = [1, 2, 3, 4]
              console.log("List start: " + myList)
              myList.unshift(99)
              console.log("List unshifted: " + myList)
              

              Returns in console window (with Qt 5.12.10):

              List start: 1,2,3,4
              List unshifted: 99,1,2,3,4
              
              SPlattenS Offline
              SPlattenS Offline
              SPlatten
              wrote on last edited by
              #6
              This post is deleted!
              1 Reply Last reply
              0

              • Login

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