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.
  • S Offline
    S Offline
    SPlatten
    wrote on 16 Feb 2021, 10:25 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.

    K 1 Reply Last reply 16 Feb 2021, 10:30
    -1
    • S SPlatten
      16 Feb 2021, 10:25

      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.

      K Offline
      K Offline
      KroMignon
      wrote on 16 Feb 2021, 10:30 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)

      S 1 Reply Last reply 16 Feb 2021, 10:34
      6
      • K KroMignon
        16 Feb 2021, 10:30

        @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
        S Offline
        S Offline
        SPlatten
        wrote on 16 Feb 2021, 10:34 last edited by
        #3

        @KroMignon , thank you

        K 1 Reply Last reply 16 Feb 2021, 10:41
        0
        • J Online
          J Online
          J.Hilk
          Moderators
          wrote on 16 Feb 2021, 10:39 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
          • S SPlatten
            16 Feb 2021, 10:34

            @KroMignon , thank you

            K Offline
            K Offline
            KroMignon
            wrote on 16 Feb 2021, 10:41 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)

            S 1 Reply Last reply 16 Feb 2021, 10:44
            2
            • K KroMignon
              16 Feb 2021, 10:41

              @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
              
              S Offline
              S Offline
              SPlatten
              wrote on 16 Feb 2021, 10:44 last edited by
              #6
              This post is deleted!
              1 Reply Last reply
              0

              1/6

              16 Feb 2021, 10:25

              • Login

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