How "bad" is this constructor?

Following the HTML5 stone, JSHint web audio tutorial gives this warning ...

W056 - Bad constructor.at line 26 col 73 

For the next line ...

 var audioContext = new (window.AudioContext || window.webkitAudioContext)(); 

The JSHint docs explain that a warning is issued whenever a new one is used with an object literal, and then say that the new one is "only useful for instantiating a constructor function and does not make sense when applied to non-functional objects or literals."

It strikes me as a reasonable use, though, it is eloquent, and it is pretty obvious what it does. So I decided to throw the ignore / * jshint -W056 * / directive, but I thought I would ask in case I missed something.

So, am I missing something?

+8
javascript jshint
source share
1 answer

The message you receive does not match the code. New used with design function. JSHint probably can't say that, though because of a complex expression. So this is wrong if it makes no sense.

+1
source share

All Articles