Ecma262: The length of DataView constructor doesn't match between the spec and implementations

Created on 28 Jan 2017  路  7Comments  路  Source: tc39/ecma262

https://tc39.github.io/ecma262/#sec-dataview-buffer-byteoffset-bytelength

24.2.2.1 DataView ( _buffer_ [ , _byteOffset_ [ , _byteLength_ ] ] )

https://tc39.github.io/ecma262/#sec-ecmascript-standard-built-in-objects

Unless otherwise specified, this value is equal to the largest number of
named arguments shown in the subclause headings for the function description.
Optional parameters (which are indicated with brackets: [ ]) or rest
parameters (which are shown using the form 芦...name禄) are not included in the
default argument count.

There is no explicit note for DataView constructor's length, so it should follow the above, and DataView.length should be 1.

Many implementations, however, return 3 for DataView.length.

  • Firefox Nightly 54.0a1 (2017-01-27) (64-bit)
  • Google Chrome Canary 58.0.2995.0 (Official Build) canary (64 bit)
  • WebKit 10.0.2 (12602.3.12.0.1, r211319)
    (haven't checked on Edge since I don't have environment to test trunk)

Most helpful comment

If changing DataView's length from 3 to 1 is the final call for ES2017, we should also consider to change the length of the TypedArray constructors from 3 to 1, because all those constructors have the same signature: ( buffer [ , byteOffset [ , length ] ] ) (ignoring the other overloaded definitions for TypedArray constructors).

Also: test262 still expects DataView.length === 3.

All 7 comments

The value is 1 in Edge 39.15014.

Unless you think it's not web compatible for those browsers to fix the length to 1, then could you file bugs on each of them to fix it?

If changing DataView's length from 3 to 1 is the final call for ES2017, we should also consider to change the length of the TypedArray constructors from 3 to 1, because all those constructors have the same signature: ( buffer [ , byteOffset [ , length ] ] ) (ignoring the other overloaded definitions for TypedArray constructors).

Also: test262 still expects DataView.length === 3.

Bump

Closing per committee consensus to leave the length at 1.

Was this page helpful?
0 / 5 - 0 ratings