archives

« Bugzilla Issues Index

#4533 — Object.keys is missing "length" note


Object.keys doesn't specify (as most other methods do) that it should have a length of 1.


The default length for functions as specified in ch. 17 applies for Object.keys, therefore it is not needed to explicitly specify the length property. Redundant function length definitions should be avoided (bug 4442).


(In reply to André Bargull from comment #1)
> The default length for functions as specified in ch. 17 applies for
> Object.keys, therefore it is not needed to explicitly specify the length
> property. Redundant function length definitions should be avoided (bug 4442).

Given that, are there any occurrences in the entire spec of functions whose length doesn't follow the rules in Chapter 17?

I think there's value in explicitly mentioning both the name and the length on every function - implementors get this wrong periodically.


(In reply to Jordan Harband from comment #2)
> Given that, are there any occurrences in the entire spec of functions whose
> length doesn't follow the rules in Chapter 17?

Yes, there are plenty of functions which don't use the default length per ch17:

Object.assign: Default 1, Actual 2
Object.prototype.toLocaleString: Default 2, Actual 0
Number.prototype.toLocaleString: Default 2, Actual 0
Date.prototype.toLocaleDateString: Default 2, Actual 0
Date.prototype.toLocaleString: Default 2, Actual 0
Date.prototype.toLocaleTimeString: Default 2, Actual 0
String.fromCharCode: Default 0, Actual 1
String.fromCodePoint: Default 0, Actual 1
String.prototype.concat: Default 0, Actual 1
String.prototype.endsWith: Default 2, Actual 1
String.prototype.includes: Default 2, Actual 1
String.prototype.indexOf: Default 2, Actual 1
String.prototype.lastIndexOf: Default 2, Actual 1
String.prototype.localeCompare: Default 3, Actual 1
String.prototype.normalize: Default 1, Actual 0
String.prototype.startsWith: Default 2, Actual 1
String.prototype.toLocaleLowerCase: Default 2, Actual 0
String.prototype.toLocaleUpperCase: Default 2, Actual 0
Array.from: Default 3, Actual 1
Array.prototype.concat: Default 0, Actual 1
Array.prototype.copyWithin: Default 3, Actual 2
Array.prototype.every: Default 2, Actual 1
Array.prototype.fill: Default 3, Actual 1
Array.prototype.filter: Default 2, Actual 1
Array.prototype.find: Default 2, Actual 1
... more