Object Methods

Master this topic with zero to advance depth.

Expert Answer & Key Takeaways

Mastering Object Methods is essential for high-fidelity technical architecture and senior engineering roles in 2026.

JavaScript Object Methods

Object methods are actions that can be performed on objects. A JavaScript method is a property containing a function definition.

1. The this Keyword in Methods

In an object method, this refers to the object. In the example below, this refers to the person object:
const person = { firstName: "John", lastName: "Doe", id: 5566, fullName: function() { return this.firstName + " " + this.lastName; } };
When you call person.fullName(), this is bound to the person instance.

2. Accessing Object Methods

You access an object method with the following syntax:
name = person.fullName();
[!WARNING] If you access the method without parentheses, it will return the function definition instead of the result.
name = person.fullName; // returns function() { return this.firstName ... }

3. Adding a Method to an Object

Adding a new method to an object is easy:
person.name = function() { return this.firstName + " " + this.lastName; };

4. ES6 Shorthand for Methods

Since 2015, you can use a shorter syntax for method definitions in object literals:
const person = { firstName: "John", fullName() { return this.firstName; } };

Top Interview Questions

?Interview Question

Q:What does 'this' refer to inside an object method?
A:
In an object method, 'this' refers to the object that 'owns' or is calling the method.

?Interview Question

Q:What happens if you use an arrow function as an object method?
A:
Arrow functions do not have their own 'this'. If used as a method, 'this' will refer to the surrounding lexical scope (usually the global window object), which is often not what you want for a method.

?Interview Question

Q:Is a method different from a regular function?
A:
Technically, a method is just a function that is stored as a property of an object. The main practical difference is its access to the 'this' context of that object.

Course4All Engineering Team

Verified Expert

Senior Full-Stack Engineers & V8 Experts

Our JavaScript and engine-level content is developed by a collective of senior engineers focused on high-performance web architecture and 2026 standards.

Pattern: 2026 Ready
Updated: Weekly