I wrote some code in chrome console to get all the functions on a webpage:
for(var b in window) {
if(typeof(b) == "function") console.log(b);}
however although there are functions on the webpage the only output i get is "undefined"
for(var b in window) {
Here, you're iterating through keys, not properties of the object. typeof of those keys is string, hence the condition under the if will never be fulfilled. And the undefined you get printed in the console is the value of the for statement (which is undefined).
Do instead
for(var b in window) {
if(typeof(window[b]) == "function") console.log(window[b]);}
If we consider your code, 'typeof(b) == "function" ' it will never check this condition because typeof(b) is always a string.
The basic syntax to get a "string" key is obj["stringFormatKey"]. So here is the solution.
for(var b in window) {
if(typeof(window[b]) == "function") console.log(b);}
bwill loop on property not value. Usetypeof(window[b])instead.