1

I am trying to figure out how some minified and possible highly-obfuscated JavaScript works. There are thousands of lines spanning multiple JS files. I have had a lot of success debugging it in my Chromium browser using dev tools and local overrides where I can refactor code without losing it on the next page load.

What's giving me problems are all the anonymous functions and types that look they were transpiled from TypeScript. They look like this:

var main = {
    someFunction: function(a,b,c,d,e) {
        //do a ton of stuff here
    },
    anotherFunction: function(d,e,f,g,h,i) {
        //even more stuff
    },
    someProperty: { json object with more members }
}

If that were a class/object in .NET in the Visual Studio IDE, I would have all kinds of tools to help me figure out how such an object is built, all the places its members are referenced, etc. With a dynamic language like JavaScript, though, regular browser debuggers lack the information needed to give me that kind of insight into the code. Therefore, when I need to see where a property is initially set, there's no way to look for all the places it's referenced. You can use CTRL+F, but, if there are multiple objects with the same property names, it's not a very effective approach.

If I had the debugging power of an IDE such as Visual Studio, it would make reverse engineering this code so much easier. How can you make debugging JavaScript just as straight-forward?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.