Instagram | Twitter | LinkedIn
What is the output of the following code ?
A. ["๐ฎ", "๐ฅ", "๐"]
B. ReferenceError
C. ["๐", "๐ฅ", "๐"]
๐ Click here to see the correct answer and explanation
| Correct Answer | Explanation |
|---|---|
| C. ["๐", "๐ฅ", "๐"] | Arrays are object in JavaScript and they are passed and assigned by reference. Changing the first element of the clothes, will also modify food: That is, food and clothes point to the same object in memory ๐ง |
If you want to know more about "by reference vs. by value" ๐๐ผ Explaining Value vs. Reference in Javascript | Medium and All you need to know on by reference vs by value | freeCodeCamp
ยฟ Quรฉ imprime el siguiente cรณdigo ?
A. ["๐ฎ", "๐ฅ", "๐"]
B. ReferenceError
C. ["๐", "๐ฅ", "๐"]
๐ Haz click aquรญ para ver la respuesta correcta y su explicaciรณn
| Respuesta correcta | Explicaciรณn |
|---|---|
| C. ["๐", "๐ฅ", "๐"] | Los arrays son objetos en JavaScript y se pasan y asignan por referencia. Si cambiamos el primer elemento de clothes tambiรฉn se modificarรก el array de food, ya que, food y clothes apuntan al mismo objeto en la memoria ๐ง |
Te dejo estos artรญculos por si quieres saber mรกs sobre el paso por valor y paso por referencia ๐๐ผ Explaining Value vs. Reference in Javascript | Medium and All you need to know on by reference vs by value | freeCodeCamp


Pueden consultar el siguiente material: https://es.javascript.info/array