Register to get access to free programming courses with interactive exercises

About JS: Introduction to Object Oriented Programming (OOP)

The data that we need to receive, process, store, and output to the user is the most decisive element when writing code. Some data are simple, such as those represented by strings (texts from books) or arrays (chat messages), and some are quite complex, such as information about users, which can include dozens or hundreds of properties. Below is an example using a Hexlet student:

// Very simplistic, in reality it's more complicated
const student = {
  name: 'Peter',
  encryptedPassword: ...,
  facebookId: ...,
  payments: [/* payment information */],
  currentGroup: ...,
  finishedCourses: [/* list of courses taken */]

One way to handle such data is to build the handler functions, for example, a function for changing the password. This approach is called procedural programming:

// carries out encryption internally and updates the user
// functions mutate user
changePassword(user, 'new secret password');
addFinishedCourse(user, finishedCourse);

Another way is to add methods to objects and use them:

user.changePassword('new secret password');

Object-oriented programming refers to the approach in which the code is a collection of objects that interact with one another (OOP). Objects, in this approach, are not simply the data type “object”, they're entities that have behavior, i.e., methods for working with them.

Studying OOP

Object-oriented programming is a vast subject that pervades all aspects of JavaScript development. It is the subject of several courses that cover a wide range of topics, from syntactic constructions to approaches to code organization.

This course introduces basic concepts and syntax and touches a little on the features of JavaScript that make it stand out from other OOP languages. The others are more about the principles of building OOP-style programs and, finally, the insides of JS itself, such as prototypes.

Main topics:

  • Objects
  • Classes
  • Encapsulation
  • Data hiding
  • Exceptions

These topics are extremely important even for novice JS developers because they'll start dealing with these concepts quite literally from the first day of their new job. On the other hand, it takes a lot of time before you can really make good use of the approaches and techniques you're learning. We will return to the object-oriented programming topic more than once in our courses and deepen not only our understanding of it but also deal with its syntactical matters, such as constructors and prototypes.

Hexlet Experts

Are there any more questions? Ask them in the Discussion section.

The Hexlet support team or other students will answer you.

About Hexlet learning process

For full access to the course you need a professional subscription.

A professional subscription will give you full access to all Hexlet courses, projects and lifetime access to the theory of lessons learned. You can cancel your subscription at any time.

Get access
hours of theory

Sign up

Programming courses for beginners and experienced developers. Start training for free

  • 130 courses, 2000+ hours of theory
  • 1000 practical tasks in a browser
  • 360 000 students
By sending this form, you agree to our Personal Policy and Service Conditions

Our graduates work in companies:

<span class="translation_missing" title="translation missing:">Bookmate</span>
<span class="translation_missing" title="translation missing:">Healthsamurai</span>
<span class="translation_missing" title="translation missing:">Dualboot</span>
<span class="translation_missing" title="translation missing:">Abbyy</span>
Suggested learning programs
Development of front-end components for web applications
10 months
from scratch
Start at any time

Use Hexlet to the fullest extent!

  • Ask questions about the lesson
  • Test your knowledge in quizzes
  • Practice in your browser
  • Track your progress

Sign up or sign in

By sending this form, you agree to our Personal Policy and Service Conditions
Toto Image

Ask questions if you want to discuss a theory or an exercise. Hexlet Support Team and experienced community members can help find answers and solve a problem.