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 reported by Rollbar 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, Facebook or Linkedin.

 

Banner


Microsoft Is Ending Support For Windows Android Subsystem
07/03/2024

Microsoft has announced that it is ending support for running Android applications under Windows 11. The support will cease next year. This announcement was followed rapidly by Amazon announcing the e [ ... ]



JConference January 2024 Sessions Now Online
23/02/2024

The talks presented at the 4th JChampions Conference which took place between Jan 25 to Jan 30, are now available for free on YouTube. Topics ranged from Code and Tech to Career Advice.


More News

raspberry pi books

 

Comments




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

Last Updated ( Tuesday, 26 March 2019 )