Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialOussama Moulana
2,977 PointsWhat is an instance and component ?
Hello everyone,
I did almost all JavaScript basics courses, it was great and i'm pretty sure that i understood a lot about arrays and objects. And i'm very happy that i could understand objects here, now i'm trying to learn Vue.js elsewhere since Vue.js courses are not available yet on treehouse.
The problem is the course talk a lot about Instance and sometimes component, and i google it but i'm still not able to visualize that in my mind. Could you please show me some courses here where i can learn more about instance and component, i know there is some on java, but i don't know java ..
If someone could help me or explain me that would be great Thanx
3 Answers
Steven Parker
231,248 PointsThe concept of a component is a small code subset that performs a particular task, perhaps in a generic way that can be useful in more than one program. For examples, you might have a code component that gets temperature information from a weather API, or one that converts a recipe from English to metric units. More elaborate components are sometimes called "widgets" or "plug-ins".
An instance is just a single object that was created from a class. You'd typically use the "new" operator with a constructor function or class name to create an instance. While a class is generic, an instance is specific. For example, you might have a class called "Dog" but create an instance named "Spot".
Oussama Moulana
2,977 PointsOhh I got it. Didn't know Spot the dog before today.
Awesome, I'll check this out.
Steven Parker
231,248 PointsI should've mentioned that "Spot" would be the name of a particular dog. In the US, stories about a dog named "Spot" are generally part of the very first written material a child learns to read.
Oussama Moulana
2,977 PointsYeah i saw some video on youtube, it was funny to say to myself that i'm watching Spot the dog to learn JavaScript Thanx again Steven :)
Oussama Moulana
2,977 PointsOussama Moulana
2,977 PointsThank you for your answer Steven, now i have a pretty nice vision with your explanation about component
For instance i need to know what is a constructor first and then try ton understand, but what is the relation about "Dog" and "Spot"?
Steven Parker
231,248 PointsSteven Parker
231,248 PointsMy point was that a class represents a kind of thing, and an instance a particular thing. So you might have a class named "Dog" that defined the general properties of any dog, but an instance named "Spot" that represents one specific dog.
Did your courses include Object-Oriented JavaScript? Constructors and instances are covered there.