-
-
Save ilearnjavascript/a3baecb88887e16c1d412c21b530a995 to your computer and use it in GitHub Desktop.
es6 - new methods - 9.js
This file contains 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
var arr = [1, 2, 3, 4]; | |
// fill with 0 from position 2 until position 4 | |
console.log(arr.fill(0, 2, 4)); | |
// outputs: [1, 2, 0, 0] | |
// fill with 5 from position 1 | |
console.log(arr.fill(5, 1)); | |
// outputs: [1, 5, 5, 5] | |
// fill only with 6 | |
console.log(arr.fill(6)); | |
// outputs: [6, 6, 6, 6] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment