0

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?

6
  • developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/… Commented Jul 27, 2017 at 18:09
  • Yes, thank you for that reference Amy. I did pull up that link myself but still could not understand the Class that the Javascript Date Object belongs to? What is the NAME of the class that the js object belongs to? Commented Jul 27, 2017 at 18:14
  • See Benefits of prototypal inheritance over classical?. JavaScript does not use classical class-based inheritance. Commented Jul 27, 2017 at 18:14
  • @Donna .... It's the Date class. It doesn't "belong" to anything. Commented Jul 27, 2017 at 18:17
  • Cool thanks Amy and Trincot.. I am just beginning to understand the fact that Js doesn't have the concept of class.. which initially went over my head. Its Prototypes.. and I'm reading on it now from the link Anurag sent below. Thanks all! Commented Jul 27, 2017 at 18:22

2 Answers 2

1

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/

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you!! This might be what I am looking for. Was trying to wrap my head around .. but where is the Class for these js objects? Never heard of prototypes before but this is starting to make sense!
So basically, In javascript we don't have class. We consider one base object or a function and use it as a class for other object created by new operator or Object.create syntax.
0

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:

1 Comment

Thank you I am beginning to see it now. Literally spent the last few days determined to find the class lol. I finished a course in javascript in codeacademy then really wanted to get the basics of programming because I read that coding and programming is not the same.. then I started to go deep into the basics of programming .. classes, objects, etc.. anyway thank you for your answer!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.