Sample Video Frame

Created by Zed A. Shaw Updated 2024-02-17 04:54:36
 

21: Simple OOP

To start you off I am going to build up a very tiny little object-oriented system using just data objects and functions. JavaScript has had quite a few iterations of its object-oriented programming system (OOP). By building a very simple one we can look at the internals of how OOP might work before diving into the new way that you build classes and objects.

In JavaScript ES6 there was a new and cleaner way to do object-oriented programming that fixed many of the issues from all of the previous versions of JavaScript. I am only going to teach that version because it is easier to understand and cleaner for most people to use. I recommend that you learn about the previous versions only if you happen to need to code in old JavaScript code. The new way to do OOP is mostly just a syntactic sugar over the old ways. What I'm showing you here is just a simple version of doing something like OOP and is not meant to be the old way to do OOP.

Let's say we want to write some JavaScript to store information about a person named Frank. Obviously the easiest way to do that is with an object:

Previous Lesson Next Lesson

Register for Learn JavaScript the Hard Way

Register today for the course and get the all currently available videos and lessons, plus all future modules for no extra charge.