Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
22
Task/Arrays/JavaScript/arrays.js
Normal file
22
Task/Arrays/JavaScript/arrays.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
// Create a new array with length 0
|
||||
var myArray = new Array();
|
||||
|
||||
// Create a new array with length 5
|
||||
var myArray1 = new Array(5);
|
||||
|
||||
// Create an array with 2 members (length is 2)
|
||||
var myArray2 = new Array("Item1","Item2");
|
||||
|
||||
// Create an array with 2 members using an array literal
|
||||
var myArray3 = ["Item1", "Item2"];
|
||||
|
||||
// Assign a value to member [2] (length is now 3)
|
||||
myArray3[2] = 5;
|
||||
|
||||
var x = myArray[2] + myArray.length; // 8
|
||||
|
||||
// You can also add a member to an array with the push function (length is now 4)
|
||||
myArray3.push('Test');
|
||||
|
||||
// Elisions are supported, but are buggy in some implementations
|
||||
var y = [0,1,,]; // length 3, or 4 in buggy implementations
|
||||
Loading…
Add table
Add a link
Reference in a new issue