Skip to content

Instantly share code, notes, and snippets.

@wojtrawi
Created August 26, 2023 11:01
Show Gist options
  • Save wojtrawi/eb9d4c544c64368bde4d3c4494e2c1ac to your computer and use it in GitHub Desktop.
Save wojtrawi/eb9d4c544c64368bde4d3c4494e2c1ac to your computer and use it in GitHub Desktop.
const cars = ['Ford Mustang', 'BMW M5', 'Porsche 911'];
const updatedCars = cars.slice();
updatedCars[1] = 'Mercedes AMG GT R';
console.log(cars);
// ['Ford Mustang', 'BMW M5', 'Porsche 911']
console.log(updatedCars);
// ['Ford Mustang', 'Mercedes AMG GT R', 'Porsche 911']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment