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 trialDennis Le
12,872 PointsInstance...what is he talking about?
It is confusing how Andrew is using the word "instance" explaining javaScript. When he should be using the word "object "... Especially, when taking the quizzes , he ask to create an instance when it should be an object.
From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Details_of_the_Object_Model
Defining a class by MDN......
"In class-based languages, you define a class in a separate class definition. In that definition you can specify special methods, called constructors, to create instances of the class. A constructor method can specify initial values for the instance's properties and perform other processing appropriate at creation time. You use the new operator in association with the constructor method to create class instances.
JavaScript follows a similar model, but does not have a class definition separate from the constructor. Instead, you define a constructor function to create objects with a particular initial set of properties and values. Any JavaScript function can be used as a constructor. You use the new operator with a constructor function to create a new object. (by MDN)"
These is also a chart on the site....showing the comparison of class java and prototype-base java script.....
5 Answers
Jacob Bergdahl
29,119 PointsAn object is a broad term -- everything in object-oriented programming is an object. Instance is more accurate. For example, in var dice = new Dice(), dice is an instance of Dice. This terminology is used for, as far as I'm aware, every single object-oriented programming language. Thus, the terminology used by the teacher is correct. You are indeed creating an object, but more precisely, it's an instance of a class.
I hope this clears it up a little.
jcorum
71,830 PointsAgreed. It's confusing! For the rest of the world an instance of a class is an object.
Dennis Le
12,872 PointsThanks...agreed as well
jcorum
71,830 PointsI think Dennis was referring to this statement (made at 3:37):
For values and behavior to be shared between instances of objects.
Dennis Le
12,872 PointsYes. around that time...thank you
Dennis Le
12,872 Points@Jacob...no worries...thank you
Dennis Le
12,872 PointsDennis Le
12,872 PointsJacob Thanks for the response ...So are you saying that JavaScript has classes? I thought javaScript was classless meaning prototype-based language. Thank again...I will look into it more...
Jacob Bergdahl
29,119 PointsJacob Bergdahl
29,119 PointsThe classes in Javascript are merely syntactic sugar, true, so it was wrong of me to use the word class; that's just an old habit. Nonetheless, every object in JavaScript is an instance of the object Object, and thus everything is an instance. Still, we usually only use the word instance in combination with the new keyword or something similar. You can read more here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Introduction_to_Object-Oriented_JavaScript.