JAVASCRIPT

How to debug using javascript console

learn javascript
Written by encodedBicoding

how to debug using javascript console

 

The skill to identify the debuggers needed to debug your javascript code is one skill every software engineer should possess as debuggers are the one secret tool every software developer/engineer utilizes while they build any software. As newbies software engineers, you too can harness the power that comes with using debuggers. In javascript, one of the main debuggers you would use when it comes to client-side engineering, is the console.

The console is built into many popular browsers, such as:

1. Chrome

2. Firefox

3. Safari

4. Opera

5. Edge

 

What is Debugging?

Debugging is simply the process of detecting errors which may arise in the process of developing software, and reducing such errors(bugs). It can also include the ability to test your code as you develop.

Note: There are many reason why you need to debug your code.

Reasons could include, but not limited to…

1. A program is not working efficiently

2. You want to test how a function works before implementing it in your code

3. Your data suddenly has an undefined value.

 

How to use Chrome to debug your javascript code.

  • Open the chrome browser (desktop)
  • On the right-side of the app, you will find the options menu, click and select more
    tools
  • Hover or click on it, another box will open, find developer tools and click on it.

debug javascript with chrome

How to use Safari to debug your javascript code.

  • Open the safari browser (desktop)
  • On the menu tab, click on Safari and select preferences
  • Click on advanced and check show develop menu in menu bar
  • On the menu bar, click on develop and click on show javascript console.

debug js with safari step onedebug js with safari step twodebug js with safari step three

How to know if your debugger works with your code.

In a javascript file in your project, simply console.log('any value'), you should see it in the debugging tool of your chosen.

 

Learn more about Javascript Datatypes:

An introduction to javascript data types

About the author

encodedBicoding

Software Engineer || Tech Enthusiast.
Ex @andela
Github: https://github.com/encodedBicoding
Geek Name: EncodedBicoding
Real Name: Dominic Isioma Olije

Leave a Comment