Thursday, November 13, 2025
HomeLanguagesJavascriptJavaScript Object Methods

JavaScript Object Methods

Object Methods in JavaScript can be accessed by using functions. Functions in JavaScript are stored as property values. The objects can also be called without using brackets (). 

  • In a method, ‘this’ refers to the owner object.
  • Additional information can also be added along with the object method.

Syntax: 

objectName.methodName()

Properties: A function may be divided into different property values, which are then combined and returned together. 
For Ex: The student function contains the properties: 

  • name
  • class
  • section

Return Value: It returns methods/functions stored as object properties.

Example 1: This example uses function definition as the property value. 

Javascript




// Object creation
let student = {
    name: "Martin",
    class: "12th",
    section: "A",
 
    studentDetails: function () {
        return this.name + " " + this.class
            + " " + this.section + " ";
    }
};
 
// Display object data
console.log(student.studentDetails());


Output

Martin 12th A 

Example 2: This example uses storing property values and accessing without bracket (). 

Javascript




// Object creation
let student = {
    name: "Martin",
    class: "12th",
    section: "A",
 
    studentDetails: function () {
        return this.name + " " + this.class
            + " " + this.section + " ";
    }
};
 
// Display object data
console.log(student.studentDetails);


Output

[Function: studentDetails]

Example 3: Using function definition as property value and accessing with additional details. 

Javascript




// Object creation
let student = {
    name: "Martin",
    class: "12th",
    section: "A",
 
    studentDetails: function () {
        return this.name + " " + this.class
            + " " + this.section + " ";
    }
};
 
// Display object data
console.log("STUDENT " + student.studentDetails());


Output

STUDENT Martin 12th A 

Supported Browsers:

  • Google Chrome
  • Microsoft Edge
  • Firefox
  • Safari
  • Opera
RELATED ARTICLES

Most Popular

Dominic
32399 POSTS0 COMMENTS
Milvus
95 POSTS0 COMMENTS
Nango Kala
6765 POSTS0 COMMENTS
Nicole Veronica
11916 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11983 POSTS0 COMMENTS
Shaida Kate Naidoo
6889 POSTS0 COMMENTS
Ted Musemwa
7141 POSTS0 COMMENTS
Thapelo Manthata
6835 POSTS0 COMMENTS
Umr Jansen
6838 POSTS0 COMMENTS