Cargo Cult Code Generation
Javascript Errors in the Wild Recently, I came across this code in the popular Axios library:
function AxiosError(message, code, config, request, response) { Error.call(this); // some more code i've left out for brevity } What does Error.call(this) do, you might ask? Nothing! I’ve tried it out in Node versions back until 6, Spidermonkey and JavaScriptCore. None of them do anything to the this object of the Error constructor. Moreover, the specification says that you have to be able to call the Error constructor without new, so it makes sense to implement it that way.