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


Wasmer 5 Adds iOS Support
12/11/2024

The Wasmer team has released Wasmer 5.0. The WebAssembly runtime adds experimental support for more back ends including V8, Wasmi and WAMR. It also now has iOS support, and upgraded compilers includin [ ... ]



Looking Forward To NAO 7
03/11/2024

Introduced to the world in 2004 by its creator Bruno Maisonnier the kid-sized, autonomous humanoid robot NAO, turns 20 this year. At less than 2 ft tall, it is small in stature, but plays a big r [ ... ]


More News

espbook

 

Comments




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

Last Updated ( Tuesday, 26 March 2019 )