HISE Logo Forum
    • Categories
    • Register
    • Login

    Print Object Value for Object Key; not working

    Scheduled Pinned Locked Moved Scripting
    22 Posts 3 Posters 1.4k 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.
    • d.healeyD
      d.healey
      last edited by d.healey

      Here's a quick guide

      //Objects store data in key/value pairs
      var obj = {};
      
      //The key is like an array index
      var keyValuePair = {"key":"value"};
      
      //Objects can store multiple key/value pairs
      var multipleKeyValuePairs = {"key1":"value1", "key2":"value2"};
      
      //Arrays don't have keys, they have indexes
      var array = [];
      
      //The first array index is always 0
      var arrayWithValues = ["value1", "value2", "value3"];
      
      //You can put an array inside an object.
      var arrayInsideObject = {"key":["value1", "value2", "value3"]};
      
      //To access the array inside the object you need to use the key
      var arr = arrayInsideObject.key;
      
      //You can also write it like this
      arr = arrayInsideObject["key"];
      
      //To access the contents of the array that's inside the object you need the key and the array index
      var index = 0; //This is the index of the first item in the array, "value1"
      var value = arrayInsideObject["key"][index];
      
      

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

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

        @d-healey said in Print Object Value for Object Key; not working:

        Here's a quick guide

        //Objects store data in key/value pairs
        var obj = {};
        
        //The key is like an array index
        var keyValuePair = {"key":"value"};
        
        //Objects can store multiple key/value pairs
        var multipleKeyValuePairs = {"key1":"value1", "key2":"value2"};
        
        //Arrays don't have keys, they have indexes
        var array = [];
        
        //The first array index is always 0
        var arrayWithValues = ["value1", "value2", "value3"];
        
        //You can put an array inside an object.
        var arrayInsideObject = {"key":["value1", "value2", "value3"]};
        
        //To access the array inside the object you need to use the key
        var arr = arrayInsideObject.key;
        
        //You can also write it like this
        arr = arrayInsideObject["key"];
        
        //To access the contents of the array that's inside the object you need the key and the array index
        var index = 0; //This is the index of the first item in the array, "value1"
        var value = arrayInsideObject["key"][index];
        
        

        Helped Alot!
        Big thanks!
        Even though i pretty much knew it all, your example really put it in perspective!

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

        11

        Online

        1.8k

        Users

        11.9k

        Topics

        103.9k

        Posts