Skip to content

Instantly share code, notes, and snippets.

@ilearnjavascript
Created March 27, 2019 23:20
Show Gist options
  • Save ilearnjavascript/a3baecb88887e16c1d412c21b530a995 to your computer and use it in GitHub Desktop.
Save ilearnjavascript/a3baecb88887e16c1d412c21b530a995 to your computer and use it in GitHub Desktop.
es6 - new methods - 9.js
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