Javascript Notes – Adding Methods to Objects

We can add functions to objects, as properties, and when that is done they are referred to as methods.

So why would we want to add methods to objects? Why not just keep our functions separate?

And if we run that in the console we get:

and an alternate way to add functions to objects is like this:

and we can see that that works in the console and returns the expected values:

and that gives us the following result:

+ There are no comments

Add yours