Clase 6 Flashcards

1
Q

Tipos de arrays

A

const arrayA = [];
const arrayB = [1,2];
const arrayC = [‘A’,’B’];
const arrayD = [true,false];
const arrayE = […arrayA,…arrayB,…arrayC,…arrayD];

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Acceder Array Js

A

console.log(arrayE[2])

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Recorrer Array Js

A

for(let i = 0 ; i < arrayE.length ; i++){
console.log(arrayE[i])
}

for(let i of arrayE){
console.log(i)
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Metodo ES6 JS
Agregar

A

console.log(arrayE.push(‘Final’))
console.log(arrayE.unshift(‘Inicio’))

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Metodo ES6 JS
Eliminar

A

console.log(arrayE.pop())
console.log(arrayE.shift())
console.log(arrayE.splice(2,1))

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Metodo ES6 JS
String

A

console.log(arrayE.join(“- “))

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Metodo ES6 JS
Concat

A

console.log(arrayE.concat(arrayB))

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Metodo ES6 JS
indexOf

A

console.log(arrayE.indexOf(2))

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Metodo ES6 JS
includes

A

console.log(arrayE.includes(2))

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Metodo ES6 JS
slice

A

console.log(arrayE.slice(2,4))

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Metodo ES6 JS
Reverse

A

let reversaArray = arrayE;
console.log(reversaArray.reverse())
Cuidado destructivo

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

OBJETOS JS

A

const objeto1 = {id:1,producto:’Papas’};
const array = [objeto1,{id:2,producto:’Arroz’}]
array.push({id:3,producto:’Ensalada’})

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Recorrer un array JS

A

for(const valor of array){
console.log(valor.producto)
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Clase producto con constructor de nombre y precio y un metodo sumarIva a los productos. JS

A

class Producto{
constructor(nombre,precio){
this.nombre = nombre;
this.precio = precio;
}

sumarIva(){
    this.precio += this.precio * 0.19;
} }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Push a array de elemento con instanciación de la clase. JS

A

let productos = []
const productoUno = productos.push(new Producto(‘Pollo’,5000))
const productoDos = productos.push(new Producto(‘Ensaladada’,3000))

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Recorrer array y aplicar un metodo a los elementos. JS

A

for(const valor of productos){
valor.sumarIva()
}

17
Q

Mostrar los elementos de un array usando forEach JS

A

productos.forEach(elemento => {
console.log(elemento)
});