Object and Arrays – Reference vs Copy

Screenshot of working through the “Object and Arrays – Reference vs Copy” tutorial.

This tutorial worked through the differences between referring to a variable, array or object.

There were a couple key takeaways I found interesting with this exercise.

The first was that if you let one variable be assigned a value, then refer that variable to a new one and then reassign the first variable this doesn’t change the second.

Next I learnt three ways of copying an array. I think my favourite is using the spread syntax as follows:

const showHosts = ['Pinacolada Soundsystem', 'Fraserhead', 'Dave Branton', 'Dr Hitchcock'];const eightKayMembers = […showHosts];