Once thing I was made aware of today was that not everyone knows the magic "debugger;" command. I suppose this makes sense; I rarely see it mentioned, but it is a very useful debugging command in the JavaScript world.
The "debugger;" command is used to cause the application to stop and enter the debugger at that point. This works in Node.js, the browsers, and even in NativeScript! In a browser the developer tools must be open; if your debugger tools are closed; it will ignore it. In node, a debugger must already be attached or it will also ignore it.
In NativeScript it will actually halt the program and WAIT until a debugger is attached! So don't release your code
So pretend my code in main-page.js is
function pageLoaded(args) { var page = args.object; debugger; // do something with the page object. }
You can then start the application on the device; and it will automatically stop right at that debugger; statement. Then at the command line type: tns run android --start and you will be in the debugger right at that line.