vOrchestrator gotcha when working with arrays

Ok, so I just wasted 30 minutes debugging the logic of my script, I have run in to this before but had forgotten about it.

Beware of arrays as object properties…

So at first glance you’d think that this code would be just fine, I mean, what is wrong with initializing a variable property as an array and then pushing object to it?

However, this will not work. You can’t push objects in to the array property once you assign it to the object. So you have to change your code to something like this:

 As you can see, instead of initializing spec.vAppConfig.property as an array and pushing objects to that array, instead I had to create a new array object, push objects to it and then assign it to spec.vAppConfig.property. Not a big deal but it can make the logic of the code messier.

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">