JavaScript/Notes/Debugging: Difference between revisions

From Noisebridge
Jump to navigation Jump to search
No edit summary
No edit summary
Line 13: Line 13:


2) Bring up the debugger from the menu.
2) Bring up the debugger from the menu.
[[File:Debugger.jpg]]
[[File:Debugger.png]]


2) Add a breakpoint manually.
2) Add a breakpoint manually.

Revision as of 16:34, 30 December 2013

A few approaches: 1) Use the debugger keyword: <source lang="javascript"> function myFunc(myParam) {

 debugger;
 var myVar = 1;
 
 function innerFunc() {
 
 }

} </source>

2) Bring up the debugger from the menu.

Error creating thumbnail: Unable to save thumbnail to destination

2) Add a breakpoint manually.

<source lang="html5"> <!doctype html> <head> <title>Debugger Example</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body>

Test Debugger

When Entering an Execution Context, the Variable Environment is initialized with parameter variables, Function Declarations, and Variable Statements.

function myFunc(myParam) {
  debugger;
  var myVar = 1;
  
  function innerFunc() {
  
  }
}

<script> function myFunc(myParam) {

 debugger;
 var myVar = 1;
 
 function innerFunc() {
 
 }

} </script>

Open the debugger and then click the button below.

<button onclick="myFunc(7)">myFunc(7)</button> </body> </html> </source>