0

Debugging javascript in chrome, how can i change the names of the variables in the debugger (_17, _18...) for the real names of the variables in source code?

            if (_17) {
                try {
                    var _18 = _17(_c);
                    if (_18 && typeof _18.then === "function") {
                        _18.then(_6.hitch(_16.deferred, "resolve"), 
puki
  • 33
  • 1
  • 7
  • Those are the variable names. Are you debugging minified code? In that case you probably want [source maps](https://developers.google.com/web/tools/chrome-devtools/javascript/source-maps). – Karl Reid Jun 22 '17 at 17:51
  • [this question is basically the same (Check second answer)](https://stackoverflow.com/questions/4603021/is-it-possible-to-change-javascript-variable-values-while-debugging-in-google-ch) – J. Lavoie Jun 22 '17 at 17:51
  • @J.Lavoie: No, that's something else entirely. – T.J. Crowder Jun 22 '17 at 17:53
  • Check this link (second answer)[link](https://stackoverflow.com/questions/4603021/is-it-possible-to-change-javascript-variable-values-while-debugging-in-google-ch) – J. Lavoie Jun 22 '17 at 17:53
  • 1
    @J.Lavoie: That's the same link you already posted. If you're trying to link directly to [the second answer](https://stackoverflow.com/a/4603111/157247), right click the word "share" on the answer and choose "Copy link address" (or whatever it is on your browser). But again, that question and its answers are irrelvant here. – T.J. Crowder Jun 22 '17 at 17:55

3 Answers3

1

You need to use source maps when you build your code, then hook them up properly. That's what'll tell Chrome (and other modern browsers) what the real code is and it should link it up for you.

How you generate source maps depends on exactly how you build and minify your code.

samanime
  • 25,408
  • 15
  • 90
  • 139
1

Whatever minifier/compressor you're using should have an option to produce a "source map" which can be used, along with the original pre-minified source code, to allow you to debug while looking at your original source code even though the browser is running the minified version. If the map exists and is alongside the generated .js file, Chrome will pick it up automatically.

That said, normally you wouldn't minify source code during development.

More about Chrome's support for source maps here.

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
-1

You can click with the right button in a variable that has been logged and save it to use as a temporary local variable.

netoguimaraes
  • 405
  • 2
  • 4