Said flexibility is a double edged sword. On one hand it gives developers a lot of freedom, but on the other it can lead to unexpected behaviour and increased cognitive load trying to keep track of what’s actually going on.
In this article we’re going to look at property descriptors — a feature introduced in ES5 that can help control (and even extend) behaviour and provide a bit of order in the this crazy, dynamic…
In my last post about the prototype chain, I touched very briefly on the
this keyword and binding — and now the time has come to give it our full attention.
To really understand the behaviour of
this, there are 4 binding rules we need to pay attention to.
As a quick overview, here they are in ascending order of precedence (lowest to highest):
Now, for the…
You can get by just fine without delving too deeply, or even thinking about prototypes. Where it starts getting more interesting though, is when we throw constructor functions and classes into the mix.
So, let’s dive in 🤿
You can see the prototype an object is pointing to using…