Return all of the functions that are defined in a Javascript file

Here is a function that will return all functions defined in the document, what it does is it iterates through all objects/elements/functions and displays only those whose type is “function”.

function getAllFunctions(){ 
        var allfunctions=[];
          for ( var i in window) {
        if((typeof window[i]).toString()=="function"){
            allfunctions.push(window[i].name);
          }
       }
    }


Here is a jsFiddle working demo.

​Add the function at the last and this snippet getAllFunctions().slice(48, -4) will just return the user defined functions in Vivaldi.

Leave a Comment