Book Image

VMware vRealize Orchestrator Essentials

By : Daniel Langenhan
Book Image

VMware vRealize Orchestrator Essentials

By: Daniel Langenhan

Overview of this book

Table of Contents (18 chapters)
VMware vRealize Orchestrator Essentials
About the Author
About the Reviewers

Working with arrays

We have already taken a look at different variable types, but there is a special type that we should explore a bit more—the array. Any variable type can be made into an array. An array is a container that holds multiple values of the same variable type. For example, an array of the String variable type may contain values such as "Mum", "Dad", "Sister", and "Brother", whereas an array of VC:VirtualMachine may contain multiple VMs.

Arrays in JavaScript

In JavaScript, you can use several methods to start, define, and initialize an array. The following are some of these methods:

  • By defining its content:

    var family = new Array("Mum", "Dad", "Sister", "Brother");
  • Using a more compact style:

    var family=["Mum", "Dad", "Sister", "Brother"];
  • Alternatively, if you want to initialize an empty array, just use the following:

    var family = new Array();
  • If you want to add an element to an array, you just push it in:


Typically, we access the content of an array via JavaScript...