Demo
View Source
Click here to convert CSV to fruits array:
Convert to Array
var str = "apple, peaches, oranges, mangoes";