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];
-
@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!