Pages

Friday, January 18, 2019

Mapping a constructed Javascript array

Array(100) produces vacant array. Execution of map function will lead undefined.
 
 We need to use spread operator to use map function successfully.
 
 
const arr = [...Array(100)].map((_, i) => i); 
 
 
Source: Shawn Reisner' blog entry

No comments :

Post a Comment