Javascript Array flatMap() convert sentence list to word list

Description

Javascript Array flatMap() convert sentence list to word list

let arr1 = ["this is a test", "test test", "css Java"];

let a = arr1.map(x => x.split(" "));
console.log(a);/*from   w  ww  .j  a v  a2  s.  co m*/

a = arr1.flatMap(x => x.split(" "));
console.log(a);



PreviousNext

Related