HISE Logo Forum
    • Categories
    • Register
    • Login

    Alternative for ".shift()" for arrays?

    Scheduled Pinned Locked Moved Scripting
    6 Posts 3 Posters 311 Views
    Loading More Posts
    • 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.
    • Alex ParadisA
      Alex Paradis
      last edited by

      Hi everyone,

      Is there an alternative for using the function ".shift()", which removes the first element in an array?

      1 Reply Last reply Reply Quote 0
      • d.healeyD
        d.healey
        last edited by

        var fruits = ["Banana", "Orange", "Apple", "Mango"];
        fruits.remove(fruits[0]);
        

        Libre Wave - Freedom respecting instruments and effects
        My Patreon - HISE tutorials
        YouTube Channel - Public HISE tutorials

        Alex ParadisA 1 Reply Last reply Reply Quote 0
        • Alex ParadisA
          Alex Paradis @d.healey
          last edited by

          @d-healey said in Alternative for ".shift()" for arrays?:

          fruits.remove(fruits[0]);

          I was trying to remove the item only by its index...

          Works like a charm now. Thanks!

          LindonL 1 Reply Last reply Reply Quote 0
          • LindonL
            Lindon @Alex Paradis
            last edited by

            @Alex-Paradis please take some time with this sort of thing to check things like this:

            Link Preview Image
            W3Schools.com

            Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.

            favicon

            (www.w3schools.com)

            HISE Development for hire.
            www.channelrobot.com

            Alex ParadisA 1 Reply Last reply Reply Quote 0
            • Alex ParadisA
              Alex Paradis @Lindon
              last edited by

              @Lindon
              In fact, this is where I found the function and saw that code.

              var fruits = ["Banana", "Orange", "Apple", "Mango"];
              fruits.shift();
              

              I didn't know that for Hise you also have to add the array plus its index in the "remove()" function but anyway, it's all good for now.

              LindonL 1 Reply Last reply Reply Quote 0
              • LindonL
                Lindon @Alex Paradis
                last edited by

                @Alex-Paradis then you probably also saw this one:

                Link Preview Image
                W3Schools.com

                Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.

                favicon

                (www.w3schools.com)

                HISE Development for hire.
                www.channelrobot.com

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post

                22

                Online

                1.8k

                Users

                12.0k

                Topics

                104.5k

                Posts