JavaScript Methods Worksheet

Question 1

How is a method different from a regular function in JavaScript?

a method is a function that is added to an object. For the most part it is the same as a function created outside an object expect when calling/invoking a method you have to include the object.method().

Question 2

Why would we want to add methods to an object?

We would add to methods to an obejct so we can simulate a certian behavoir that is part of the object and can be seen as self-contained.

Question 3

How can we access the property of an object from inside the body of a method of that object?

We would use the dot operator but also the key word of 'this'

Coding Problems

Coding Problems - See the 'script' tag below this h3 tag. You will have to write some JavaScript code in it.

Always test your work! Check the console log to make sure there are no errors.