DEV Community

Tri Nguyen
Tri Nguyen

Posted on • Updated on

3 coding habits to unblock yourself (Part 2)

Hello fellow coders.
welcome back to part 2 of some good habits to unblock yourself. If you missed the 1st part you can check it out right here:
https://dev.to/trilemaestro92/3-coding-habits-to-unblock-yourself-part-1-9lg

Lets get started!

ERROR REFERENCE

In part one I talked about console log and how it can help beginners like me see the errors and where they're located. In this article I will discuss the habit of learning error messages.

JavaScript coding in particular is prone to errors due to its complex nature. Errors occur where you least expect them and they are one of the main cause of JS developer's banging their head in confusion.

But fear not, I believe if you can build a habit of learning or even familiarizing yourself with some common error of JavaScript, this habit can help you unblock a bug or issue more efficient.

In JavaScript there are many errors you can run across like ReferenceError, SyntaxError, RangeError, and many more. They all have different definitions and solutions. Therefore I would encourage you to start noticing some of the error code you are receiving and do a little research on them. Who knows once you come across the same error code more than once you can even built a radar for those error while coding and condition yourself to not make the same mistake.

BTW you can check JavaScript error code all out here:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors

A few common JavaScript errors

Common SyntaxError:

  1. If errors: The “==” operator performs a comparison while the “=” operator assigns a value, very easy to mix up.
  2. Mismatch brackets, case sensitive, overall spelling mistakes.

Common TypeError :

1.Using an Array method on non-Array object can cause an error to occurs, since you'll be calling a method on an undefined object.

example.

Alt text of image

map method can only be used for Array not object

2.Using null or undefined as an object. This is an error that occurs in browser when you read a property or call a method on a null or undefined object.

Those are some of common errors I've experienced. I'm certain in time my error list will grow as my knowledge on how to fix them.

Hope this article was helpful. Part 3 coming soon!

Thanks for reading me!

Top comments (0)