I have task to receive unique element in order from string as parameter. I do not understand how this function uniqueElements returns [\'A\',\'B\',\'C\',\'B\']
[\'A\',\'B\',\'C\',\'B\']
var word = "AAAABBBBCCBB"; var unique = word.split('').filter(function(item, i, ar) { return ar.indexOf(item) === i; }).join('');