DEV Community

Cover image for Object Oriented Programming (OOP)
Victoria igbobi
Victoria igbobi

Posted on

Object Oriented Programming (OOP)

I know you are wondering what OOP is right??.

The key notion of OOP is an object, an object consists of two things: data and methods(functions) that work with the data.

class

A class is a template for objects. It contains the code for all the objects method.

Basic example of class

class className {
    constructor (name) {
        this.name = name
      }
    method (){
        function body
     }
Enter fullscreen mode Exit fullscreen mode

A class must contain;

  • class Keyword

  • className, It should be nouns because classes represent concrete objects. e.g Investment.

  • Most classes have a method called constructor. The constructor is usually used to set up the class variables.

  • The class method

There we have the basics of OOP.

Top comments (1)

Collapse
 
monginadiana profile image
monginadiana

This is well captured.. Good work