I have a function to filter CSS classes for duplicates and empty spaces, but my function exports arrays with empty spaces anyway...
var classes = function (className, current) {
var classNames = [className], uniques = {};
if(current) classNames = classNames.concat(current.split(' '));
return classNames.filter(function (className,i) {
if(className == "") return;
className = className.match(/\S+/)[0];
if (!uniques[className]) return uniques[className] = className;
});
};
When I run classes(' foo') I get [" foo"] with a empty space anyway,
although console.log(' foo'.match(/\S+/)[0]; returns 'foo' with no space.
What am I missing?
' foo'into this function and get back a clean['foo']with no spaces. And I think I did everything correct but somewhere a empty space is being added and I can't find where...