r/WebdevTutorials • • Sep 05 '20

Autocomplete application using vanilla Javascript

https://www.youtube.com/watch?v=4d1DqjveJak&ab_channel=VarunGupta
35 Upvotes

6 comments sorted by

1

u/nickdevtech Sep 05 '20

I really enjoyed watching the video, you do some good explaining of all the steps! If I can point out one thing sometimes you do the if statements with curly braces and sometimes without. I would suggest always with curly braces. Because your videos are good and when you explode on Youtube, and in the future, I review code of somebody and when I see not consistent if statements and I asked them did you watch Varun Gupta and they say yes, then I wished I would have said something :P

1

u/[deleted] Sep 06 '20

Haha...thanks, much love! So what I usually go for is that if it’s a single statement then no curly braces are required but I’ll keep your suggestion in mind! :D

1

u/[deleted] Sep 06 '20

It’s actually nice for new coders to see a variety of syntax uses sometimes so they know what’s possible and it improves how they read/use it later (if they pay attention).

1

u/[deleted] Sep 06 '20

Also a fair point! I'll try to explicitly call it out the next time I use a niche syntax! Thanks!

1

u/CampbeII Sep 06 '20

I enjoyed your explanation of theory at the beginning.

Im curious as to why you didn't include a debounce function on the key events? I always thought it was essential for events that a user can trigger in quick succession.

2

u/[deleted] Sep 06 '20

Yeah you’re right! Very good point! So usually for really heavy duty functions, we don’t want them firing in quick succession since that might slow down the page. Here I didn’t do that because I really wanted to drive home the point that just how optimised these queries actually are. Even after the events firing in quick succession, there’s virtually no performance degradation! :D