Created
July 14, 2024 18:01
-
-
Save prof3ssorSt3v3/30018890d5876cbc8771935f7d62fb22 to your computer and use it in GitHub Desktop.
Code from tutorial on Array with and copyWithin methods
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
//copy = Array.prototype.with(index, value) | |
//changed = Array.prototype.copyWithin(index, start, end) | |
const names = ['Bob', 'Louise', 'Gene', 'Linda', 'Teddy']; | |
const newNames = names.with(1, 'Gayle'); // names[1] = 'Gayle' | |
console.log(names); | |
console.log(newNames); | |
console.log(names == newNames); //false | |
console.log(names === newNames); //false | |
const changed = names.copyWithin(1, 2, 3); | |
console.log(names === changed); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment