JS/TS OOP: 2-Classes And Objects
Tags: javascript, oop, typescript
Published: 2022-11-17 05:03:43

---
title: JS/TS OOP: 2-Classes And Objects
published: true
description: 
series: jstsoop
tags: javascript, oop, typescript
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hswg0pfyhic6gg25h7nc.png
# Use a ratio of 100:42 for best results.
# published_at: 2022-10-25 09:51 +0000
---

## Introduction

So we're going to start with the most important topic in OOP, which is `Classes` and `Objects`.

## What is a class?

A class is a blueprint for creating objects, it defines a set of attributes that will characterize any object of the class. The attributes are called `fields`, and the functions are called `methods`.

> This is the academic definition, but let's see our own definition.

Imagine a class like a definition of type, for example a `human` class defines the characteristics of human and his/her actions.

For example the human skin color is a `characteristic`, and the human walks, talks, eats, sleeps, etc. are `actions`.

So a class is a definition of a type, it defines the characteristics and the actions of the type.

In that sense we can say that a class is a `blueprint` or `schema` for things in life.

You can think of a class as a `template` or a **descriptive book** about a entity, how it shapes and how it acts and interacts with other types.

## What is an object?

We now know that classes are the definition of a type, so what is an object?

An object is the real thing of that blueprint, for example me and you are objects of the `Human` class.

Your `cat` at your home is an object of the `Cat` class.

So an object is the real implementation or the actual object/item of a class.

## Other terms for objects

You might read in an article, book or while watching a video the term `object`, also it is called `instance` of a class.

## 🎨 Conclusion

Classes are the `blueprints` of **things**, they are used to create objects, and objects are the real things of that blueprint.

In our next article, we'll learn about the structure of a class.

## ☕♨️ Buy me a Coffee ♨️☕

If you enjoy my articles and see it useful to you, you may [buy me a coffee](https://www.paypal.com/paypalme/hassanzohdy), it will help me to keep going and keep creating more content.

## 😍 Join our community

Join our community on [Discord](https://discord.gg/pb2vmdfhGf) to get help and support (Node Js 2023 Channel).

## 📚 Bonus Content 📚

You may have a look at these articles, it will definitely boost your knowledge and productivity.

General Topics

* [Event Driven Architecture: A Practical Guide in Javascript](https://dev.to/hassanzohdy/event-driven-architecture-the-best-paradigm-that-i-love-to-work-with-in-javascript-and-node-js-1gnk)
* [Best Practices For Case Styles: Camel, Pascal, Snake, and Kebab Case In Node And Javascript](https://dev.to/hassanzohdy/best-practices-for-case-styles-camel-pascal-snake-and-kebab-case-in-node-and-javascript-55oi)
* [After 6 years of practicing MongoDB, Here are my thoughts on MongoDB vs MySQL
](https://dev.to/hassanzohdy/after-6-years-of-practicing-mongodb-here-are-my-thoughts-on-mongodb-vs-mysql-574b)

Packages & Libraries

* [Collections: Your ultimate Javascript Arrays Manager](https://dev.to/hassanzohdy/collections-your-ultimate-javascript-array-handler-3o15)
* [Supportive Is: an elegant utility to check types of values in JavaScript](https://dev.to/hassanzohdy/supportive-is-an-elegant-utility-to-check-types-of-values-in-javascript-1b3e)
* [Localization: An agnostic i18n package to manage localization in your project](https://dev.to/hassanzohdy/mongez-localization-the-simplest-way-to-translate-your-website-regardless-your-favorite-framework-4gi3)

 React Js Packages

* [useFetcher: easiest way to fetch data in React Js](https://dev.to/hassanzohdy/usefetcher-the-easiest-way-to-fetch-data-in-react-45o9)

Courses (Articles)

* [ES6++: The Ultimate Guide to ES6 and Beyond](https://dev.to/hassanzohdy/es6-1-introduction-h3e)
* [Node Js 2023 Course: Node With Typescript, The Ultimate Guide](https://dev.to/hassanzohdy/nodejs-course-2023-introduction-to-nodejs-3n4e)
* [React Js: Let"s Create File Manager With React Js and Node Js](https://dev.to/hassanzohdy/lets-create-a-file-manager-from-scratch-with-react-and-typescript-chapter-i-a-good-way-to-expand-your-experience-5g4k)