Redux is a powerful yet simple way of managing the state of your app, but it is a purely functional library. This is something that JavaScript developers may not have had much experience with and on its surface, sounds a bit odd. The purpose of Redux is to manage state, but one of the tenants of functional programming is you can’t alter state… so what’s up with that?
To keep things functional, Redux makes heavy use of the Object.
This is a follow-up to Classes in JavaScript
In my previous post, we learned how you can create classes in JavaScript using
the new
operator and a temporary constructor function. This post will show
how you can use the Object.create() method to setup the prototype without using
new.
JavaScript doesn’t follow a classical inheritance model (although it can be
made to do so), but instead uses a prototypal inheritance model at its core.
See my introduction post on prototypes and objects
if your not clear how this works.
The idea that everything is an object in JavaScript is a bit of
a misnomer. A more accurate saying would be that nearly everything is or can
behave like an object. The reason for this is because nearly everything in
JavaScript comes from a common ancestor called Object. This relationship is
expressed through prototypes.