javascript split and trim
snippet in javascript

javascript trim

user6811

var str=" I have outer spaces ";
var cleanStr=str.trim();//trim() returns string with outer spaces removed

javascript split and trim

user5197

var arr = str.split(",").map(item => item.trim());