How to do it...

Let's examine several methods to debug code. The first one is the JavaScript console.log() method:

  1. Create a new file, name it index.html, and write the following code:
<!DOCTYPE html> 
<html> 
<head> 
    <meta charset="utf-8"> 
    <title>Debugging</title> 
</head> 
<body> 
    <script> 
        var num1 = 5; 
        var num2 = 8; 
 
        var sum = num1 + num2; 
 
        console.log(sum); 
    </script> 
</body> 
</html> 
  1. After navigating to this web page, press the F12 key on the keyboard and click on the Console tab. You should see 13 as follows (the screenshot is taken from the Google Chrome browser, but it's almost identical in other browsers):

If we want to see a variable's ...

Get ASP.NET Core MVC 2.0 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.