Can you still?

What's the output?

const food = ['馃崟', '馃崼', '馃', '馃崝'];
const info = { favoriteFood: food[0] };

info.favoriteFood = '馃崫';

console.log(food);

You missed this one before

We set the value of the favoriteFood property on the info object equal to the string with the pizza emoji, '馃崟'. A string is a primitive data type. In JavaScript, primitive data types don't interact by reference.

In JavaScript, primitive data types (everything that's not an object) interact by value. In this case, we set the value of the favoriteFood property on the info object equal to the value of the first element in the food array, the string with the pizza emoji in this case ('馃崟'). A string is a primitive data type, and interact by value (see my blogpost (opens in a new tab) if you're interested in learning more)

Then, we change the value of the favoriteFood property on the info object. The food array hasn't changed, since the value of favoriteFood was merely a copy of the value of the first element in the array, and doesn't have a reference to the same spot in memory as the element on food[0]. When we log food, it's still the original array, ['馃崟', '馃崼', '馃', '馃崝'].

Question 109 路 see the original (opens in a new tab)