Last active
August 5, 2020 02:09
-
-
Save apassiondev/107c97d36558645e88d12203ad245720 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @type: JavaScript | |
* @todo Find all methods of an object | |
*/ | |
const listMethods = obj => Object.getOwnPropertyNames(obj).filter( | |
item => typeof obj[item] === 'function' | |
) | |
// example | |
const food = { | |
title: 'Dumpling', | |
rating: '4', | |
taste: () => console.log('Tasty') | |
} | |
console.log(listMethods(food)) | |
// References: https://flaviocopes.com/how-to-list-object-methods-javascript/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment