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


Random Gifts For Programmers
24/11/2024

Not really random. Not even pseudo random, more stuff that caught my attention and that I, for one, would like to be given. And, yes, if I'm not given them, I'd probably buy some for myself.



Gifts For Geeks 2024
22/11/2024

Are you ready for Thanksgiving, when overeating remorse and a surfeit of being thankful causes the unsettling thought that there are only four weeks till the Xmas break? So here is a mix of weird [ ... ]


More News

espbook

 

Comments




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

Last Updated ( Tuesday, 26 March 2019 )