JavaScript Methods Worksheet
Question 1
How is a method different from a regular function in JavaScript?
the primary distinction between a method and a regular function lies in their association with objects.
A method is a function that is a property of an object, whereas a regular function is defined independently of any object.
Question 2
Why would we want to add methods to an object?
Adding methods to an object in JavaScript allows the object to have behavior along with its data.
This makes the object more useful and helps organize related functionality within the object itself.
Question 3
How can we access the property of an object from inside the body of a method of that object?
We can access the property of an object from inside the body of a method by using the this keyword.
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.