delete a property from an Object



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

    delete Object.property;
    

    is there a similar operator for Hise script?



  • 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));
    


  • @d-healey thank you David


Log in to reply
 

13
Online

1.2k
Users

3.9k
Topics

34.4k
Posts