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. …
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.
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! …
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.
Software Developer working for Ramsey Solutions in Nashville, Tennessee.