locked
javascript environment RRS feed

  • Question

  • Is there a way to get the names of all the functions defined in the current page? I know I can look at the JavaScript, but there is a lot (most of it I did not write). I know I can use a debugger to traverse the DOM, but where would I find the functions.



    Thanks

    Monday, January 7, 2008 7:18 PM

All replies

  • This code depends on the context. Make sure you run it in the global context where you want to get the names:

    for (name in this) {
    
    if (typeof this[name] === 'function')
    console.log("this[" + name + "]=" + this[name]);
    }



    Dalorzo

    Sunday, November 17, 2013 3:29 PM