Learn JavaScript
this on Objects

Shorthand for method

We can declare a function inside the object and directly assign it to a property.

In the example given below, we are declaring the function inside the admin object and assign it to the sayHello property.

However, we can choose not to write the word “function”.

In the example given above, we are creating the sayHello method using a shorter syntax.