{"id":239,"date":"2016-02-19T18:07:08","date_gmt":"2016-02-19T18:07:08","guid":{"rendered":"http:\/\/fluentreports.com\/blog\/?p=239"},"modified":"2016-02-19T18:07:08","modified_gmt":"2016-02-19T18:07:08","slug":"nativescriptjavascript-tip-debugging","status":"publish","type":"post","link":"https:\/\/fluentreports.com\/blog\/?p=239","title":{"rendered":"NativeScript\/JavaScript Tip: Debugging"},"content":{"rendered":"<p>Once thing I was made aware of today was that not everyone knows the magic \"<strong>debugger;<\/strong>\" command.\u00a0\u00a0 I suppose this makes sense; I rarely see it mentioned, but it is a very useful debugging command in the JavaScript world.<\/p>\n<p>The \"<strong>debugger;<\/strong>\" command is used to cause the application to stop and enter the debugger at that point.\u00a0\u00a0 This works in Node.js, the browsers, and even in NativeScript! \u00a0\u00a0 In a browser the developer tools must be open; if your debugger tools are closed; it will ignore it.\u00a0\u00a0\u00a0\u00a0 In node, a debugger must already be attached or it will also ignore it.<\/p>\n<p>In NativeScript it will actually halt the program and WAIT until a debugger is attached!\u00a0\u00a0 So don't release your code<\/p>\n<p>So pretend my code in main-page.js is<br \/>\n<pre>function pageLoaded(args) {\nvar page = args.object;\ndebugger;\n\/\/ do something with the page object.\n}\n<\/pre><br \/>\nYou can then start the application on the device; and it will automatically stop right at that <strong>debugger;<\/strong> statement.\u00a0\u00a0 Then at the command line type: <strong><em>tns run android --start<\/em><\/strong> and you will be in the debugger right at that line.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Once thing I was made aware of today was that not everyone knows the magic \"debugger;\" command.\u00a0\u00a0 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&hellip; <a class=\"more-link\" href=\"https:\/\/fluentreports.com\/blog\/?p=239\">Continue reading <span class=\"screen-reader-text\">NativeScript\/JavaScript Tip: Debugging<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[3,15,39],"tags":[56,22,16],"class_list":["post-239","post","type-post","status-publish","format-standard","hentry","category-javascript","category-nativescript","category-tips","tag-debugging","tag-javascript","tag-nativescript","entry"],"_links":{"self":[{"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/239","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=239"}],"version-history":[{"count":1,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/239\/revisions"}],"predecessor-version":[{"id":240,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/239\/revisions\/240"}],"wp:attachment":[{"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=239"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=239"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=239"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}