A quick look at handling asynchronous code in JavaScript.

Photo by Ethan Kent on Unsplash

Like a dog waiting for their human to return, programmers often wait for their code to return something. Perhaps it’s JSON from a REST endpoint you hit from the client. Perhaps it’s a record from a database you queried from the server.

Perhaps it’s the human, coming home with treats.

Thankfully, we can do other stuff while we wait! A program can continue executing other code while requests for external resources continue to sit patiently in the background, stepping out of the way so that other code can continue to run.

What is a closure in JavaScript? Why do closures matter? How do you use closures?

Photo by Pablo Guerrero on Unsplash

Seeing as MDN’s page on closures defines it extremely well, I’m not going to reinvent the wheel here:

A closure is the combination of a function bundled together (enclosed) with references to its surrounding state (the lexical environment).

Let’s unpack this concept a bit.

The first thing I want to point out is that whenever you define a function, you are making a choice about its lexical environment, whether intentional or unintentional, conscious or…maybe you’re unconscious. I don’t know.

In many cases, the lexical environment…

A quick look at using event delegation instead of placing multiple event listeners on a page.

Photo by Payam Tahery on Unsplash

This article is part of a series on digestible code concepts for folks newer to web development, who are searching for better approaches to solving problems with code.

Imagine a web page adorned with a lake of buttons. Each one of those buttons does something beautiful and life changing. How would you make each of those buttons do something unique?

With event listeners! …

Photo by Nathan Dumlao on Unsplash

So about two years ago, I quit my sales job to pursue a career in software development. I’m now a developer at a financial wellness company called Ramsey Solutions (best thing I’ve ever done career-wise).

That’s enough about me. You came here for code nuggets.

As a relatively new developer wanting to help other new developers, I am going to be writing an article series on digestible code concepts that will help unpack simple but powerful ideas.

These articles are going to cover fun little JavaScript concepts that don’t take much time to learn, but will give you that satisfying…

Bobby Tate

Software Developer working for Ramsey Solutions in Nashville, Tennessee.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store