You can use Object.getOwnPropertyNames() to get all properties that belong to an object, whether enumerable or not. For example:

console.log(Object.getOwnPropertyNames(Math));
//-> ["E", "LN10", "LN2", "LOG2E", "LOG10E", "PI", ...etc ]

You can then use filter() to obtain only the methods:

console.log(Object.getOwnPropertyNames(Math).filter(function (p) {
    return typeof Math[p] === 'function';
}));
//-> ["random", "abs", "acos", "asin", "atan", "ceil", "cos", "exp", ...etc ]

In ES3 browsers (IE 8 and lower), the properties of built-in objects aren't enumerable. Objects like window and document aren't built-in, they're defined by the browser and most likely enumerable by design.

From ECMA-262 Edition 3:

Global Object
There is a unique global object (15.1), which is created before control enters any execution context. Initially the global object has the following properties:

• Built-in objects such as Math, String, Date, parseInt, etc. These have attributes { DontEnum }.
• Additional host defined properties. This may include a property whose value is the global object itself; for example, in the HTML document object model the window property of the global object is the global object itself.

As control enters execution contexts, and as ECMAScript code is executed, additional properties may be added to the global object and the initial properties may be changed.

I should point out that this means those objects aren't enumerable properties of the Global object. If you look through the rest of the specification document, you will see most of the built-in properties and methods of these objects have the { DontEnum } attribute set on them.


Update: a fellow SO user, CMS, brought an IE bug regarding { DontEnum } to my attention.

Instead of checking the DontEnum attribute, [Microsoft] JScript will skip over any property in any object where there is a same-named property in the object's prototype chain that has the attribute DontEnum.

In short, beware when naming your object properties. If there is a built-in prototype property or method with the same name then IE will skip over it when using a for...in loop.

Answer from Andy E on Stack Overflow
Top answer
1 of 11
391

You can use Object.getOwnPropertyNames() to get all properties that belong to an object, whether enumerable or not. For example:

console.log(Object.getOwnPropertyNames(Math));
//-> ["E", "LN10", "LN2", "LOG2E", "LOG10E", "PI", ...etc ]

You can then use filter() to obtain only the methods:

console.log(Object.getOwnPropertyNames(Math).filter(function (p) {
    return typeof Math[p] === 'function';
}));
//-> ["random", "abs", "acos", "asin", "atan", "ceil", "cos", "exp", ...etc ]

In ES3 browsers (IE 8 and lower), the properties of built-in objects aren't enumerable. Objects like window and document aren't built-in, they're defined by the browser and most likely enumerable by design.

From ECMA-262 Edition 3:

Global Object
There is a unique global object (15.1), which is created before control enters any execution context. Initially the global object has the following properties:

• Built-in objects such as Math, String, Date, parseInt, etc. These have attributes { DontEnum }.
• Additional host defined properties. This may include a property whose value is the global object itself; for example, in the HTML document object model the window property of the global object is the global object itself.

As control enters execution contexts, and as ECMAScript code is executed, additional properties may be added to the global object and the initial properties may be changed.

I should point out that this means those objects aren't enumerable properties of the Global object. If you look through the rest of the specification document, you will see most of the built-in properties and methods of these objects have the { DontEnum } attribute set on them.


Update: a fellow SO user, CMS, brought an IE bug regarding { DontEnum } to my attention.

Instead of checking the DontEnum attribute, [Microsoft] JScript will skip over any property in any object where there is a same-named property in the object's prototype chain that has the attribute DontEnum.

In short, beware when naming your object properties. If there is a built-in prototype property or method with the same name then IE will skip over it when using a for...in loop.

2 of 11
77

It's not possible with ES3 as the properties have an internal DontEnum attribute which prevents us from enumerating these properties. ES5, on the other hand, provides property descriptors for controlling the enumeration capabilities of properties so user-defined and native properties can use the same interface and enjoy the same capabilities, which includes being able to see non-enumerable properties programmatically.

The getOwnPropertyNames function can be used to enumerate over all properties of the passed in object, including those that are non-enumerable. Then a simple typeof check can be employed to filter out non-functions. Unfortunately, Chrome is the only browser that it works on currently.

function getAllMethods(object) {
    return Object.getOwnPropertyNames(object).filter(function(property) {
        return typeof object[property] == 'function';
    });
}

console.log(getAllMethods(Math));

logs ["cos", "pow", "log", "tan", "sqrt", "ceil", "asin", "abs", "max", "exp", "atan2", "random", "round", "floor", "acos", "atan", "min", "sin"] in no particular order.

🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Object
Object - JavaScript - MDN Web Docs
In case where a semantically equivalent static method doesn't exist, or if you really want to use the Object.prototype method, you should directly call() the Object.prototype method on your target object instead, to prevent the object from having an overriding property that produces unexpected results.
🌐
Flavio Copes
flaviocopes.com › home › javascript › how to list all methods of an object in javascript
How to list all methods of an object in JavaScript - Flavio Copes
February 4, 2019 - Learn how to list the methods of a JavaScript object with Object.getOwnPropertyNames() filtered by typeof, plus how to walk the prototype chain with a Set. ~~~ To list the methods of an object, get its property names with Object.getOwnPrope...
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-get-all-the-methods-of-an-object-using-javascript
Get all the methods of an object using JavaScript - GeeksforGeeks
August 19, 2026 - The idea is to use a for-in loop to iterate over the object's enumerable properties and check each property's type using the typeof operator. If the property contains a function, its name and function definition are added to the result. Example: Gets the names and definitions of all accessible methods.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-object-methods
JavaScript Object Methods - GeeksforGeeks
July 30, 2025 - // 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);
🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-use-object-methods-in-javascript
How To Use Object Methods in JavaScript | DigitalOcean
August 26, 2021 - This tutorial will go over important built-in object methods, with each section below dealing with a specific method and providing an example of use. In order to get the most out of this tutorial, you should be familiar with creating, modifying, and working with objects, which you can review in the “Understanding Objects in JavaScript” article.
Find elsewhere
🌐
TutorialsPoint
tutorialspoint.com › get-all-methods-of-any-object-javascript
Get all methods of any object JavaScript
November 21, 2020 - const returnMethods = (obj = {}) => { const members = Object.getOwnPropertyNames(obj); const methods = members.filter(el => { return typeof obj[el] === 'function'; }) return methods; }; console.log(returnMethods(Array.prototype));
🌐
DEV Community
dev.to › hy_piyush › 10-important-javascript-object-methods-everyone-must-know-in-2023-398k
10 Important JavaScript Object Methods everyone must know in 2023 - DEV Community
January 23, 2023 - These methods allow you to interact with objects in JavaScript in a more powerful way, they allow you to create, modify, and retrieve properties and values of objects, and to manipulate the prototype chain of an object.
🌐
Medium
medium.com › youstart-labs › javascript-object-methods-every-developer-should-know-c68c132a658
Javascript Object methods every developer should know | by Abhishek Rathore | Youstart Labs | Medium
July 26, 2018 - Here you can see the name, year and speak properties. In JS methods are also properties with type function. In the next section, we will discuss copying an object properly in JS.
🌐
Web Reference
webreference.com › javascript › basics › object-methods
JavaScript Object Methods Explained
In Javascript, we have several, helpful built-in methods available to us. We can leverage them to interact with the object properties and introduce some flexibility to our code creation needs.
🌐
Medium
sreejittech.medium.com › essential-javascript-object-methods-a-comprehensive-guide-with-examples-edeb8baf5205
Essential JavaScript Object Methods: A Comprehensive Guide with Examples | by Parakkalam Sreejit | Medium
August 19, 2023 - Essential JavaScript Object Methods: A Comprehensive Guide with Examples Object Methods Here’s a list of some commonly used built-in object methods in JavaScript Object.keys(obj) - Returns an array …
🌐
JavaScript.info
javascript.info › tutorial › the javascript language › objects: the basics
Object methods, "this"
So, here we’ve got a method sayHi of the object user. Of course, we could use a pre-declared function as a method, like this:
🌐
Medium
sonikamaheshwari005.medium.com › all-about-javascript-object-object-methods-d9fa633e0210
All about JavaScript Object | Object Methods | by Sonika | @Walmart | Frontend Developer | 11 Years | Medium
August 28, 2024 - All about JavaScript Object | Object Methods Topic Covered:: JavaScript Object: Constructor Function Class Object.create() Object.keys() Object.values() Object.entries() Problem Statement on …
🌐
Playcode
playcode.io › javascript › methods
JavaScript Object Methods & the this Keyword | Playcode
Learn JavaScript object methods, define functions inside objects, understand the this keyword, use method shorthand, and avoid common mistakes.
🌐
TutorialsPoint
tutorialspoint.com › javascript › javascript_builtin_functions.htm
JavaScript Built-in Functions Reference
Here, you can find all the JavaScript's built-in methods on the following classes: The Number object contains only the default methods that are part of every object's definition.