Donna
Donna

Reputation: 7

OOP in JavaScript, what class do JavaScript objects belong to?

From my basic understanding of Object Oriented Programming, a Class is a blueprint of an Object. For example, one might say apple, oranges etc is Object of Class Fruit.

I'm not understanding the structure , please forgive the basic-ness of this question.

When I look at the JavaScript Objects, for example a Date Object, or a Time Object..

What class for example does the Date Object belong to?

Upvotes: 0

Views: 243

Answers (2)

trincot
trincot

Reputation: 350137

JavaScript does not use classical class-based inheritance, but prototyped inheritance. A Date object "inherits" from Date.prototype, which is the closest thing to the object you are looking for.

See:

Upvotes: 0

Anurag Singh Bisht
Anurag Singh Bisht

Reputation: 2753

In Javascript, there is no concept of class as in case of other programming languages.

But, we can implement OOP in Javascript through prototypes.

Prototypes are a way through which we can define methods and properties in a function, which then can be inherited by objects created using the new keyword.

For better understanding, I will suggest to go through the below link. http://javascriptissexy.com/javascript-prototype-in-plain-detailed-language/

Upvotes: 1

Related Questions