Creating a Function that can Remember Data

I recently released a tutorial about creating functions that remember data. This can also be referred as “retaining state”. This is a great feature of JavaScript and it reflects what I feel is one of the strengths of JavaScript.

This technique uses closure, but it uses it in a way that my not be intuitive, even to those that understand closure well. The basic idea is that your invoke a function that returns a function, and that returned function has access to (remembers) any data that was passed to it or establish at the time the function was returned.

This can be a powerful feature. Take a few moments and watch the tutorial and then tell me what you think.

Storing Data in a Browser

At times you may come across the need to store some data in the browser so that when the user returns, you already have that data available. This can help solve a problem that might require the connecting and passing data to a server. But I have also found situations where even though I am passing data to a server it is helpful to store some data in the browser to ease the experience for the user.

I’ve recently published two tutorials on ways to store data in the browser. One uses localStorage and the other uses indexedDB.

LocalStorage is a pretty simple solution, but it does have some limitations such as the data can only be a string and there is a limit to how much data you can store. IndexedDB overcomes those limitations, but it is not quite as simple to use as localStorage.

Watch these two tutorial to dive deep into storing data in a browser.