Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let empty_array = [];
- let array2 = [1, 1.5, false, "string", []];
- let array = [1,2,3,4];
- console.log(empty_array); // []
- console.log(array2); // [1, 1.5, false, "string", []]
- console.log(array); // [1, 2, 3, 4]
- console.log(array[0]); // 1
- console.log(array.length); // 4
- console.log(array[4]); // undefined
- array[2] = -1;
- array.push(5);
- console.log(array); // [1, 2, -1, 4, 5]
- console.log(array.length); // 5
- for(let i = 0; i < array.length; i++) {
- console.log(array[i]);
- }
- // 1, 2, -1, 4, 5 (on a separate line)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement