Objects

Let’s learn about JS objects.

What is an object?

A JavaScript object is essentially a set of key-value pairs, also called slots. In these key-value pairs names can be property names, function names, or keys of a map. JavaScript objects are different from classical object-oriented or Unified Modeling Language (UML) objects. In particular, they don’t have to instantiate a class, and they can have their own instance-level methods. That way, they not only have ordinary property slots, but method slots as well. In addition, JS objects may also have key-value slots. So, these objects may have three different kinds of slots, while classical objects (called instance specifications in UML) only have property slots.

Objects can be created as needed using JavaScript’s object literal notation (JSON) without instantiating a class, like so:

Get hands-on with 1400+ tech skills courses.