Forum

    • Register
    • Login
    • Search
    • Categories

    delete a property from an Object

    Scripting Forum
    2
    3
    59
    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.
    • ulrik
      ulrik last edited by

      In javascript I'm able to delete an Objects property by using

      delete Object.property;
      

      is there a similar operator for Hise script?

      Hise Develop branch
      MacOs 13, Xcode 14.0.1
      http://musikboden.se

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

        I don't think there is such a method. In JUCE there is a removeProperty method that might do what you need if it was wrapped into the scripting API.

        Currently you have to do it the long way

        const obj = {"dog":"1", "cat":"2", "fish":"3", "duck":"4"};
        const toDelete = ["cat", "duck"];
        const newObj = {};
        
        for (x in obj)
            if (!toDelete.contains(x))
                newObj[x] = obj[x];
        
        Console.print(trace(newObj));
        

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

        ulrik 1 Reply Last reply Reply Quote 1
        • ulrik
          ulrik @d.healey last edited by

          @d-healey thank you David

          Hise Develop branch
          MacOs 13, Xcode 14.0.1
          http://musikboden.se

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

          26
          Online

          1.1k
          Users

          7.0k
          Topics

          64.6k
          Posts