DEV Community

Cover image for 20 Important JavaScript Concepts for Your Next Interview πŸš€

20 Important JavaScript Concepts for Your Next Interview πŸš€

Jagroop Singh on November 04, 2024

When it comes to JavaScript interviews, employers are looking for practical knowledge as much as theoretical. So, here’s a list of 20 core JavaScri...
Collapse
 
john12 profile image
john

I found Debouncing & Throttling a bit complicated for me. Is it even used in real world application or not ?
Also, I found closures interesting concept.

Collapse
 
jagroop2001 profile image
Jagroop Singh

@john12 ,
Yes, debouncing and throttling are widely used in real-world applications, especially in front-end development where performance optimization is key.

1. Debouncing

  • What it does: Debouncing delays the execution of a function until a certain period of inactivity has passed.
  • Real-world example: E-commerce sites often use debounced input on search fields to avoid overwhelming the server with queries and provide a smoother experience.

2. Throttling

  • What it does: Throttling, on the other hand, limits the number of times a function is executed over a set period, regardless of how often the event occurs.
  • Real-world example: Social media feeds or infinite scroll features often use throttling to ensure that loading more content or tracking scroll position doesn’t slow down the page.

Together, these techniques prevent β€œovercalling” functions, which can lead to performance issues, especially on mobile devices or slower networks.

Also,
Closures are indeed fascinating! They allow functions to retain access to their original scope, even after that scope has finished executing.

Let me know if you’d like more examples or a breakdown of any particular concept in order to unserstand it better!

Collapse
 
hraifi profile image
sewiko

Wow nice and detailed explanation

Thread Thread
 
jagroop2001 profile image
Jagroop Singh

Thanks @hraifi

Collapse
 
john12 profile image
john

wow, you have just published another blog in the comments. Is it for real or it's GPT generated.
Well it's well explained , now I understand the whole concept of Debouncing and Throttling

Thread Thread
 
jagroop2001 profile image
Jagroop Singh

Thank you! Also, this response isn't generated by GPT. I personally invested time in crafting it to ensure that users can gain a better understanding of the concept.

Thread Thread
 
john12 profile image
john

Thank you for the efforts !!

Collapse
 
hraifi profile image
sewiko

I didn't understand the concept of Promises ??

Collapse
 
jagroop2001 profile image
Jagroop Singh

okay let me explain this with a short story,
Imagine you order a pizza. The pizza shop promises it’ll arrive soon. Right now, your order is pending. After some time, either:

  1. The pizza arrives on time, making you happy β€” this is the fulfilled state, and you enjoy your pizza.
  2. Something goes wrong (like the oven breaks), so they cancel the order β€” this is the rejected state, leaving you without pizza.

In JavaScript, a Promise works the same way! It’s like saying, β€œI promise to do something later,” and based on what happens, you either get a result (fulfilled) or an error (rejected).

Collapse
 
jagroop2001 profile image
Jagroop Singh

Thanks for this nice explanation with story.

Collapse
 
jagroop2001 profile image
Jagroop Singh

Wow !!
That look's promising !!