Difference between object oriented and object based language

Viewed 36431

What is the difference between an object oriented and an object based programming language? Is JavaScript is an object oriented or based?

5 Answers

I found there are two version of answer for this question.

Firstly, you must define what is object-oriented language.

  1. From English wiki, you can find that class-based language is object-oriented language, and prototype-based language is not object-oriented language. They think if a language only uses "object" is not enough,so it is not an object-oriented language.
  2. From mozilla, you can find that prototype-based language is object-oriented language. Because they think if a language uses "object", it is an object-oriented language. And then they divide object-oriented into two type:
    • class-based and object-based object-oriented.
    • object-based(or prototype-based) object-oriented

My English is not very good. If you are Chinese, you can see Chinese wiki.

The following example is a general usage of a class in JavaScript: image

Result in the console: image

The proto references the Animals prototype (which in turn references the Object prototype). From this, we can see that the constructor defines the major features while everything outside the constructor (sing() and dance()) are the bonus features (prototypes).

Related