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 trial

JavaScript JavaScript Functions Arrow Functions Testing for Number Arguments

karan Badhwar
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
karan Badhwar
Web Development Techdegree Graduate 18,135 Points

Error 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

Yes, 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.

Hi! 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
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
karan Badhwar
Web Development Techdegree Graduate 18,135 Points

Hi 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?