<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Topics tagged with array]]></title><description><![CDATA[A list of topics that have been tagged with array]]></description><link>https://forums.getbraincloud.com/tags/array</link><generator>RSS for Node</generator><lastBuildDate>Tue, 08 Sep 2026 15:22:01 GMT</lastBuildDate><atom:link href="https://forums.getbraincloud.com/tags/array.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 06 Mar 2022 19:21:01 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[How to add to an array in Cloud Code?]]></title><description><![CDATA[I posted this almost 13 days ago with zero answers, so I took some time to look through a bunch of documentation and did a ton of trial and error. Please Braincloud for the love of god add this to your API.
Rhino does not handle Arrays the way that other coding languages do.
I figured it out, unlike most arrays that return an array after you call push- Rhino returns the new length. So if you call push, don't set it's value.
var copyArray = []; //I assume this line tells it to be an array

for (var i = 0; i &lt; postResult.data..length; i++) 
         {
             copyArray[i] = postResult.data[i]; 
//arrays do not behave like .Net arrays, you can change length without initializing, so you just set each index to the index of the array you're copying
         }

copyArray.push(variableToAdd); 
//Do NOT set this as the value of your array, the push method returns an int (length of array) NOT an array!
//you probably dont need to call push at all to add to the array as shown in the for loop above if you already know your length or want a specific length


Then just set your value to the variable, like this
  var entityData = {
    "variableName": copyArray
};
//No need to call Array(copyArray) or any of the prototype. slice stuff. If you call Array() you'll just nest the array a second time. 

Use this page for further info on functions you can do with arrays.
]]></description><link>https://forums.getbraincloud.com/topic/145/how-to-add-to-an-array-in-cloud-code</link><guid isPermaLink="true">https://forums.getbraincloud.com/topic/145/how-to-add-to-an-array-in-cloud-code</guid><dc:creator><![CDATA[helliyum]]></dc:creator><pubDate>Sun, 06 Mar 2022 19:21:01 GMT</pubDate></item></channel></rss>