Top 10 JavaScript Errors
Written by Ian Elliot   
Monday, 29 January 2018

Know your enemy is good advice, but do you know the most common errors made in your favourite programming language? Rollbar has looked at more than 1000 real world projects and made a list of the ten most common errors in JavaScript.

Rollbar is an error logging utility that includes remote reporting so it's a natural for collecting the problems that occur with real JavaScript programs in production.

So what do you think the most common errors are going to be?

The ten errors are:

javascripterrors

 

The first two are a bit of a cheat because they are the same error as reported by Chrome and Safari, but if you look more closely most of the errors are of a single type - trying to use a property or method that an object doesn't have. At this point it is tempting to conclude "what else do you expect from a weakly typed dynamic language!". However, these are runtime errors and might well have not been picked up by strong typing.

The Rollbar blog speculates that the majority of these problems occur because of race conditions in asynchronous operations. For example, trying to access a DOM element before the component has finished loading.

Knowing that using properties or methods that don't exist is the biggest set of errors in JavaScript is interesting, but really it just confirms our expectations. What would be more interesting is really knowing why these errors occur. After all, if you make the sort of error that strong typing would pick up at compile time, then you are going to see a similar error at runtime as soon as the faulty code is executed. The question is what happens to make an object that should have a property or method not have that property or method at runtime?

The only cases I can think of are the race condition already described and similar and the occurrence of edge cases where functions fail to return an object at all.

More data required.

JSlogo

More Information

Top 10 JavaScript errors from 1000+ projects (and how to avoid them)

Related Articles

JavaScript The Language With Two Names    

The JavaScript Encyclopedia Work In Progress 

JavaScript Added To Oxford English Dictionary 

JavaScript 6 EcmaScript 2015 Final Approval 

JavaScript 20 Years Old Today 

 

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on, Twitter, FacebookGoogle+ or Linkedin.

 

Banner


Playing a Piano and Composing Reduced to Eight Keys
20/10/2018

If you have harboured a dream of just sitting down in front of a piano and playing something amazing impromptu then your dream might become a reality - and without all the hard work of learning music  [ ... ]



Ring UI Adds Light And Dark Support
09/11/2018

There's an updated version of the Ring UI controls for use when building web applications in JetBrains. The updated version handles light and dark environments as well as supporting CSS properties and [ ... ]


More News

Python

 



 

Comments




or email your comment to: comments@i-programmer.info

Last Updated ( Monday, 29 January 2018 )