Sign in

Professional Software Engineer, man of many hobbies

JavaScript is a dynamic programming language. This is great for flexibility but it can make code pretty fragile due to checks not happening until runtime.

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…


CODEX

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.

It’s one of the more confusing areas of JavaScript, so make sure your thinking hat is nearby, have a seat and let’s get into it.

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):

  • Default binding
  • Implicit binding
  • Explicit binding
  • New binding

Now, for the…


CODEX

If, like me, your previous programming experience was in Object Oriented languages like Java or C#, JavaScript’s prototype based approach to inheritance might take a minute to get your head around.

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 🤿

What is a prototype?

Every object in JavaScript can be linked to a prototype object which is the mechanism through which inheritance is provided.

You can see the prototype an object is pointing to using…

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