Explica este c贸digo JavaScript
const food = ['馃崟', '馃崼', '馃', '馃崝']
const info = { favoriteFood: food[0] }
info.favoriteFood = '馃崫'
console.log(food)
- A:
['馃崟', '馃崼', '馃', '馃崝']
- B:
['馃崫', '馃崼', '馃', '馃崝']
- C:
['馃崫', '馃崟', '馃崼', '馃', '馃崝']
- D:
ReferenceError
Respuesta en el primer comentario.
Respuesta:
A: ['馃崟', '馃崼', '馃', '馃崝']
Tenemos un arreglo food
y un objeto info
independiente uno del otro.
info
solo tiene la propiedad favoriteFood
que apunta al 铆ndice 0
del arreglo food
, por lo tanto info
seria igual a:
const info = { favoriteFood:'馃崟'}
Posteriormente pisamos o sobre escribimos este valor modifiando el emoji de pizza por uno de spaguetti:
info.favoriteFood = '馃崫'
Ahora info
se ve as铆:
const info = { favoriteFood:'馃崫'}
En ning煤n momento modificamos de ninguna manera el array food
, por ende sigue siendo el mismo: ['馃崟', '馃崼', '馃', '馃崝']