This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cars = ['Ford Mustang', 'BMW M5', 'Porsche 911']; | |
const updatedCars = cars.with(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'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cars = ['Ford Mustang', 'BMW M5', 'Porsche 911']; | |
cars[1] = 'Mercedes AMG GT R'; | |
console.log(cars); | |
// ['Ford Mustang', 'Mercedes AMG GT R', 'Porsche 911'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cars = ['Ford Mustang', 'BMW M5', 'Porsche 911']; | |
const splicedCars = cars.toSpliced(1, 1); | |
console.log(cars); | |
// ['Ford Mustang', 'BMW M5', 'Porsche 911'] | |
console.log(splicedCars); | |
// ["Ford Mustang", "Porsche 911"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cars = ['Ford Mustang', 'BMW M5', 'Porsche 911']; | |
const splicedCars = cars.slice(); | |
splicedCars.splice(1, 1); | |
console.log(cars); | |
// ['Ford Mustang', 'BMW M5', 'Porsche 911'] | |
console.log(splicedCars); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cars = ['Ford Mustang', 'BMW M5', 'Porsche 911']; | |
cars.splice(1, 1); | |
console.log(cars); | |
// ["Ford Mustang", "Porsche 911"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cars = ['Ford Mustang', 'BMW M5', 'Porsche 911']; | |
const sortedCars = cars.toSorted(); | |
console.log(cars); | |
// ["Ford Mustang", "BMW M5", "Porsche 911"] | |
console.log(sortedCars); | |
// ["BMW M5", "Ford Mustang", "Porsche 911"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cars = ['Ford Mustang', 'BMW M5', 'Porsche 911']; | |
const sortedCars = cars.slice().sort(); | |
console.log(cars); | |
// ["Ford Mustang", "BMW M5", "Porsche 911"] | |
console.log(sortedCars); | |
// ["BMW M5", "Ford Mustang", "Porsche 911"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cars = ['Ford Mustang', 'BMW M5', 'Porsche 911']; | |
const sortedCars = cars.sort(); | |
console.log(cars); | |
// ["BMW M5", "Ford Mustang", "Porsche 911"] | |
console.log(sortedCars); | |
// ["BMW M5", "Ford Mustang", "Porsche 911"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cars = ['Ford Mustang', 'BMW M5', 'Porsche 911']; | |
const reversedCars = cars.toReversed(); | |
console.log(cars); | |
// ["Ford Mustang", "BMW M5", "Porsche 911"] | |
console.log(reversedCars); | |
// ["Porsche 911", "BMW M5", "Ford Mustang"] |
NewerOlder