Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View a Javascript method's contents in Chrome console

When I console.log an object in Chrome, I see all properties and a method name, but I can't see the contents of the method itself. How can I view the contents of an object's method?

I've created a JSFiddle that may help explain what I'm looking for.

How to view a Javascript method's contents console

like image 235
dmathisen Avatar asked Jun 03 '15 16:06

dmathisen


1 Answers

Remember that function is just syntactic sugar for the Function object. Because of this Object's toString() is inherited.

So, to answer your question:

console.log(someObj.methodOne.toString()).

like image 51
deadboy Avatar answered Oct 04 '22 12:10

deadboy