Javascript Arrays Flashcards

1
Q

Definir array a

A

var a = new Array();

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

Definir array a de longitud n

A

var a = new Array(n);

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

Asignar valor x a posición n de array a

A

a[n] = x;

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

Ajustar o devolver longitud del array a

A

a.length

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

Definir array a y sus elementos x, y, z (con constructor)

A

var a = new Array(x, y, z);

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

Definir array a y sus elementos x, y, z (sin constructor)

A

var a = [x, y, z];

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

Definir array mixto (diccionario) a con claves x y valores n m

A

var a = {x : n, y : m}

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

Borrar valor de la posición n del array a

A

delete a[n];

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

Borrar valores de n lugares a partir de posición m del array a, acortando array, sustituyendolos por nuevo valor o

A

a.splice(m, n, o)

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

Devolver función que creó el prototipo del objeto array

A

Array.constructor

q

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

Permitir añadir propiedades y métodos a un Array

A

Array.prototype

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

Devolver la unión de arrays a b c

A

a.concat(b, c)

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

Unir todos los elementos del array a en un string, usando un separador “x”

A

a.join(“x”)

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

Devolver y eliminar último elemento de un array a

A

a.pop()

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

Añadir elemento x al final de un array a, y devolver nueva longitud

A

a.push(x);

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

Invertir orden de los elementos en un array a

A

a.reverse()

17
Q

Devolver y eliminar primer elemento de un array a

A

a.shift()

18
Q

Definir array bidimensional a y sus subarrays con elementos x1, x2, x3, y1, y2, y3, z1, z2, z3 (con constructor)

A

var a = new Array();
a[0] = new Array(x1, x2, x3);
a[1] = new Array(y1, y2, y3);
a[2] = new Array(z1, z2, z3);

19
Q

Definir array bidimensional a y sus subarrays con elementos x1, x2, x3, y1, y2, y3, z1, z2, z3

A

var a = [
[x1, x2, x3],
[y1, y2, y3],
[z1, z2, z3]
];

20
Q

Devolver valor de clave x del array mixto (diccionario) a

A

a.x