Monday, 19 August 2013

Understanding a Function with out and obj

Understanding a Function with out and obj

I understand the gist of this function. However I don't quite grasp what
the out=[] and obj={} are doing? Are they creating empty arrays? Anybody
have a good explanation? Thanks.
function fxeliminateduplicates(nameArray)
{
var i,
len=nameArray.length,
out=[],
obj={};
for (i=0; i<len; i++) {
obj[nameArray[i]]=0;
}
for (i in obj) {
out.push(i);
}
return out;
};

No comments:

Post a Comment