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 trialkaran Badhwar
Web Development Techdegree Graduate 18,135 PointsError Object
As we use JavaScript's in-built object i.e Math Object we use its Methods
ex- Math.random() and so on..
but over here we just used error object and we did not access any of it's Method as a object does not perform actions, so how this worked?
2 Answers
Ismael Liriano
11,490 PointsYes, It should be covered on "JavaScript Objects" or "Object-Oriented JavaScript". A constructor is basically a special method which you use when you create and initialize an object.
Ismael Liriano
11,490 PointsHi! The teacher is using the constructor's object to display the message, if the exception is thrown. You can check these articles about the Error's constructor and exception handling: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Control_flow_and_error_handling#exception_handling_statements https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/Error
karan Badhwar
Web Development Techdegree Graduate 18,135 PointsHi Ismael, Thankyou for your response. But what are constructors. As i have not been at that stage is that thing taught in the further course?
karan Badhwar
Web Development Techdegree Graduate 18,135 Pointskaran Badhwar
Web Development Techdegree Graduate 18,135 PointsOkay thankyou so much Ismael. And thankyou once again for replying instantly