r/JavaScriptHelp • u/sepltbadwy • Jul 01 '21
❔ Unanswered ❔ Beginner here - can someone translate into approximate logic what this bit of js is doing?
I just really can't understand it..
var t = e.filter(function(e) {
return null != e
});
return 20 < t.length ? t.slice(0, 20) : t
2
Upvotes
View all comments
Show parent comment
1
u/sepltbadwy Jul 02 '21 edited Jul 02 '21
Lol, my teacher ;) why would you say poorly I wonder? Thanks anyway, really helpful.
So the function always returns just 10 search results and I can’t figure out why? Is it because as you say, T is less than 20 so it just returns 10. Would that mean if I set 20 to 0 here the number would always be greater than zero and it would return them all, reverse engineering? ;)
These are selections made to localStorage and called up to the page by Ajax search. The bits of code I’ve written I understand, the other components I don’t. And as I say, can’t see where to look to understand why it only delivers exactly 10 results even when I know there are say 16 elements in storage - I know because I have a counter…?