⬅ Go back to: What is an OOP?

Creating Objects


Here's an example of object in JavaScript:

    
        const circle = {
            radius: 1,
            location: {
                x: 1,
                y: 1
            },
            draw: function () {
                console.log('draw');
            }
        };

        circle.draw()
    

The members of the object are the following:

If a member is a function, we refer to that as a method (draw is a method) then the other members are called properties.


Conclusions

In OOP, properties and methods are fundamentally different. Property is being used to hold values while a Method is being used for defining logics.