Instagram | Twitter | LinkedIn
What is the output of the following code ?
A. ["馃崒", "馃崚", "馃崏"]
B. ["馃崏", "馃崚", "馃崒"]
C. ["馃崚", "馃崒", "馃崏"]
馃憖 Click here to see the correct answer and explanation
| Correct Answer | Explanation |
|---|---|
| B | The push() method adds "馃崒" to the end of the array and the unshift() method adds "馃崏" to the beginning of the array. For this reason, the correct answer is ["馃崏", "馃崚", "馃崒"]. |
Explanation based on 馃憠馃徏 Array.prototype.push() & Array.prototype.unshift()
驴 Qu茅 imprime el siguiente c贸digo ?
A. ["馃崒", "馃崚", "馃崏"]
B. ["馃崏", "馃崚", "馃崒"]
C. ["馃崚", "馃崒", "馃崏"]
馃憖 Haz click aqu铆 para ver la respuesta correcta y su explicaci贸n
| Respuesta correcta | Explicaci贸n |
|---|---|
| B | El m茅todo push() a帽ade "馃崒" al final del array y el m茅todo unshift() agrega "馃崏" al inicio del array. Por esta raz贸n, la respuesta correcta es ["馃崏", "馃崚", "馃崒"]. |
Explicaci贸n basada en 馃憠馃徏 Array.prototype.push() & Array.prototype.unshift()


let fruits = ["馃崚"]
fruits.push("馃崒"); // fruits = ["馃崚", "馃崒"]
fruits.unshift("馃崏") // fruits = ["馃崏", "馃崚", "馃崒"]
console.log(fruits); // fruits = ["馃崏", "馃崚", "馃崒"]
Respuesta: B. ["馃崏", "馃崚", "馃崒"]
Referencia: https://es.javascript.info/array