Skip to content

Instantly share code, notes, and snippets.

@Nathan-Nesbitt
Created May 10, 2020 20:58
Show Gist options
  • Save Nathan-Nesbitt/a7b3c0c6e99822e7c696cd390ce97bbf to your computer and use it in GitHub Desktop.
Save Nathan-Nesbitt/a7b3c0c6e99822e7c696cd390ce97bbf to your computer and use it in GitHub Desktop.
Array Example JavaScript
// Creates an array //
var array = [];
// Another way of creating an array of size 2 //
var objectArray = new Array(2);
// Creates an array with some data already in it //
var arrayWithData = [1, 2, 3, 4];
// Adds a value to the array //
array.push("nathan");
// Gets the 1st element from the array //
console.log(array[0]);
// Gets the length of an array //
console.log(array.length);
@Nathan-Nesbitt
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment