Slicing an array with 'slice' method

Question | May 12, 2017 | nextptr 

Array.prototype.slice is one of the most important methods of Array. As its name suggests, slice returns a new array that contains all or some of the elements in the original array.

Here we have 3 objects - car1, car2, car3 - and an array - allCars - that contains these 3 car objects:

var car1 =  { make: 'Honda', miles: 35000 };
var car2 =  { make: 'Honda', miles: 5000 };
var car3 =  { make: 'Toyota', miles: 15000 };

// Array of all cars 
var allCars = [car1, car2, car3];

We create a new array - someCars - that contains first 2 elements from allCars by calling slice. And, then we change one of the car objects:

var someCars = allCars.slice(0,2);
// change car2
car2.miles = 6000;

What will be the output of the following comparison?

console.log( allCars[1].miles === someCars[1].miles );