how to debug the js in jsfiddle

后端 未结 7 2207
無奈伤痛
無奈伤痛 2020-12-12 23:37

I am looking at this jsfiddle: http://jsfiddle.net/carpasse/mcVfK/ It works fine that is not the problem , I just want to know how to debug through the javascript. I tried t

相关标签:
7条回答
  • 2020-12-12 23:53

    Use the debugger; statement in the code. The browser inserts a breakpoint at this statement, and you can continue in browser's debugger.

    This should work atleast in chrome and firefox. https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Statements/debugger

    angular.module('app', ['appServices'])
    .config(['$routeProvider', function($routeProvider) {
        // *** Debugger invoked here
        debugger;
        $routeProvider.
                when('/home', {templateUrl: 'home.html',   controller: HomeCtrl}).
                when('/list', {templateUrl: 'list.html',   controller: ListCtrl}).
                when('/detail/:itemId', {templateUrl: 'detail.html',   controller: DetailCtrl}).
                when('/settings', {templateUrl: 'settings.html',   controller: SettingsCtrl}).
                otherwise({redirectTo: '/home'});
    }]);
    
    0 讨论(0)
  • 2020-12-12 23:54

    In addition to the other answers.

    Very often it is useful just write debug information into the console:

    console.log("debug information here");
    

    The output is available in browsers dev tools console. Like it was logged from the usual javascript code.
    This is quite simple and effective.

    0 讨论(0)
  • 2020-12-12 23:55

    Here is another place :)

    Under the Jsfiddle.net node.

    0 讨论(0)
  • 2020-12-12 23:56

    Adding a debugger statement in the code and enable the "Developer Tools" in the bowser. Then when you are running the code in JSFiddle, the debugger will be hit!.

    0 讨论(0)
  • 2020-12-12 23:56

    The JavaScript is executed from the file ?editor_console=true in the folder result (fiddle.jshell.net)/fiddle.jshell.net/_display folder of the Sources tab of Chrome when using the developper tool. You can add breakpoints to your code then and refresh the page.

    More information on using chrome debugger can be found at Trying to debug Javascript in Chrome

    0 讨论(0)
  • 2020-12-13 00:01

    Something worth mentioning. If you are ever using chrome dev tools. Press ctrl+shift+F and you can search through all the files in the source.

    0 讨论(0)
提交回复
热议问题