Created
May 10, 2020 20:58
-
-
Save Nathan-Nesbitt/a7b3c0c6e99822e7c696cd390ce97bbf to your computer and use it in GitHub Desktop.
Array Example JavaScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sample code for https://nathan.nesbitt.ca/blog-posts/IntroductionToJavascript.html