JavaScript array split string kosong

const str = ' apple banana kiwi ';

const result = str.split(' ').filter(element => element);
console.log(result); //['apple', 'banana' , 'kiwi']
Diz Andriana