-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist.js
More file actions
34 lines (26 loc) · 767 Bytes
/
list.js
File metadata and controls
34 lines (26 loc) · 767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
let otherObj = {id: 07};
let arreglo = [1, "helloworld",false, {name: "Mike"}, null, undefined, otherObj];
//Agregar contenido
arreglo.push("Agregado",{num: 08});
console.log(arreglo);
arreglo.unshift("Agregado al principio");
console.log(arreglo);
//Eliminar contenido
arreglo.pop();
console.log(arreglo);
arreglo.shift();
console.log(arreglo);
//Método para eliminar, modificar o añadir valores en arreglos
let myArray = ['H','E','L','L','O'];
//delete
myArray.splice(2,1);
console.log(myArray);
// Add
myArray.splice(4,0,'W','O','R','L','D');
console.log(myArray);
//Update
myArray.splice(2,0,'l');
console.log(myArray);
myArray.splice(2,1,'L');
console.log(myArray);
//Los valores que se añaden se añadiran a la izquierda o antes del valor señalado.