Creado por Alexandre Petit
hace más de 6 años
|
||
Pregunta | Respuesta |
What's the difference between == and === ? | == (equality) depends on the value === (identity) depends on the value and the data type |
What happens if you try to access the 10th element of an array initially declared to have 5 elements? | As sizing array is very dynamic, the array will automatically resize to accomodate the requested length. |
What does the "concat" method on an array? | it combines two arrays and returns all the elements from both the arrays. ex : array1.concat(array2); |
What do the indexOf and lastIndexOf methods on an array? | it determines the index of an element searching in an ascending order or descending order (if lastIndexOf). It accepts 2 parameters, the element and the index at wich to begin searching. ex : var index = array1.indexOf('array2', 0); |
What does the join method on an array? | it joins all the elements in an array into a single string separated by a specified string separator. ex : var join = array1.join('-'); |
What does the reverse method on an array? | it reverses the sequence of all elements in an array. ex : var numbers = new Array('1','2','3'); numbers.reverse() will give an Array('3','2','1'). It does not return anything |
What does the sort method on an array? | it sequences the items in an array in ascending order. It does not return anything |
What does the slice method on an array? | it takes out one or more items in an array and move them to a new array. ex : var num = new Array('1','2','3'); var num2 = num.slice(0, 1); will give a num2 containing only the number 1. |
What does the splice method on an array? | it provides a way to replace items in an array with new items. ex : var num = new Array('1','2','3'); var num2 = num.splice(1,2,'4'); will give a num2 containing 1, 4 and 3 |
What do push and pop method on an array? | They add and remove the last item of a list. pop returns the item removed. As if the array was a stack. |
What do shift and unshift method on an array? | shift remove and return the first element of an array. unshift insert a new element at the beginning of the array. |
¿Quieres crear tus propias Fichas gratiscon GoConqr? Más información.