This project is read-only.

Value of type 'ArrayBuffer' is not newable

Topics: General
Oct 2, 2012 at 5:19 PM

why do I get this error?

Value of type 'ArrayBuffer' is not newable

with this code

if (!DataView)
	function DataView(atype)
        	new atype();

Oct 2, 2012 at 11:00 PM
Edited Oct 2, 2012 at 11:01 PM

If you look at the docs for DataView you'll see that the first argument passed to the constructor is an existing ArrayBuffer instance.  Since it's expecting an existing instance you can't call 'new'.  If you change your call to "new ArrayBuffer();" you still ge an error because ArrayBuffer's constructor wants a length parameter.  The error goes away if you change it to "new ArrayBuffer(32);"