Improving the performance of the recursive Fibonacci implementation using closures in JavaScript
Improving the performance of the recursive Fibonacci implementation using closures in JavaScript

If you ever encountered yourself doing some practice on recursion, I’m quite sure you faced the Fibonacci sequence algorithm. If you are not familiar with this problem, take a look at what Wikipedia has to say about it:

In mathematics, the Fibonacci numbers, commonly denoted Fn, form a sequence called the Fibonacci sequence, such that each number is the sum of the two preceding ones.

So, if we start with 0 and 1, this is how the first N Fibonacci numbers look like:

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...

As you can see, each number…


You may already be familiar with the function JSON.stringify, which can be useful when comparing objects, implementing RESTFUL APIs or simply deep cloning a javascript object (although, it’s not recommended).

In this article, we are going to talk about how to create our own simplified version of this method, and learn how to improve its implementation step by step, covering more and more cases as we progress.

If you are not familiar with this function, let’s take a look at what MDN has to say about it:

The JSON.stringify() method converts a JavaScript object or value to a JSON string…


Most developers today, know about closures in Javascript. Don’t be sad if you don’t, it’s not something you generally use on your every-day work (well, you may, but it’s not so common).

If you haven’t heard yet about closures, I recommend you to read this article: https://medium.com/javascript-scene/master-the-javascript-interview-what-is-a-closure-b2f0d2152b36

Closures are something that many companies would like you to know before working for them, therefore, chances are they’ll ask you something related with this topic, or even more, they could make you write a practical example of it.

On this story, I’m gonna tell you about a small function I was asked…


On a recent technical interview I had for a big tech company, in one of the steps of the process I was asked the following:

Create a countdown from 1:30 to zero using plain javascript and HTML, and that’s all.

“Cool”, I said to myself, that’s something I can achieve easily. The total time I had to develop that was 45 minutes, which at first looked more than enough.

I started doing the simplest thing I could imagine, mimicking what a normal clock or countdown does: at each 1-second interval, we would decrease the value of the counter by 1…

Juan Dalmasso

Web Developer

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