Create an array

Constants
const cars = [
  "Saab",
  "Volvo",
  "BMW"
];

const cars = [];
cars[0]= "Saab";
cars[1]= "Volvo";
cars[2]= "BMW";
Variables

var cars = [
  "Saab",
  "Volvo",
  "BMW"
];

var cars = [];
cars[0]= "Saab";
cars[1]= "Volvo";
cars[2]= "BMW";

Array Length

  if (MyArray.count > 0)

Does array index exist?

if(typeof MyArray[index] === 'undefined')
{
    //Does not exist
}


if(typeof MyArray[index] !== 'undefined')
{
    //Does exist
}

Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

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