Skip to content

Instantly share code, notes, and snippets.

@vvatikiotis
Last active April 26, 2020 19:05
Show Gist options
  • Save vvatikiotis/7710619f0a9ed97a39433c2a11347ff2 to your computer and use it in GitHub Desktop.
Save vvatikiotis/7710619f0a9ed97a39433c2a11347ff2 to your computer and use it in GitHub Desktop.
JS Array times
Array.from(Array(3)).forEach((x, i) => {
something();
});
Array.from({ length: 3 }, (x, i) => {
something();
});
Array(5).fill().map(()=>{
// Do this 5 times:
console.log(111)
})
[...Array(3)].forEach(( _, index) => console.log('do something'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment