While following a HTML5 rocks web audio tutorial JSHint gives this warning...
W056 - Bad constructor.at line 26 col 73
For the following line...
var audioContext = new (window.AudioContext || window.webkitAudioContext)();
The JSHint docs explain the warning is issued whenever new is used with an object literal and go on to say that new "is only useful for creating instances of a constructor function and has no sensible meaning when applied to non-function objects or literals."
This strikes me as a reasonable use though, it's succinct and it's pretty obvious what it's doing. I'm therefore minded to throw in an ignore directive /*jshint -W056 */ but I thought I'd ask in case I'm missing something.
So, am I missing something?
The message you're getting doesn't match the code. New is used with a constructor function. JSHint probably can't tell this though because of the complex expression it's coming from. So it's wrong about there being no sensible meaning.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With