Open rauschma opened 6 years ago
@Flooorent Thanks! Will be fixed in the next release.
31.8.2.1 Creating holes
Either I misunderstood what you are trying to convey here, or there is a false statement:
It looks like statement that array.keys() would not reveal empty slot is false, while Object.keys() indeed, wouldn't reveal empty slots:
P.S. This difference is presently described in 31.8.2.2 How do Array operations treat holes? and it conflicts with above statement as well.
@ivansvlv A hole is revealed if you can see that its index is missing. With .keys()
, you can’t tell the difference between a hole and an element that is undefined
:
> const hole = [,]; const undef = [undefined];
> [...hole.keys()]
[ 0 ]
> [...undef.keys()]
[ 0 ]
With Object.keys()
, you can – it reveals the hole:
> Object.keys(hole)
[]
> Object.keys(undef)
[ '0' ]
@ivansvlv A hole is revealed if you can see that its index is missing. With
.keys()
, you can’t tell the difference between a hole and an element that isundefined
:> const hole = [,]; const undef = [undefined]; > [...hole.keys()] [ 0 ] > [...undef.keys()] [ 0 ]
With
Object.keys()
, you can – it reveals the hole:> Object.keys(hole) [] > Object.keys(undef) [ '0' ]
I see, I've misinterpreted "reveal the hole". Sorry for the confusion!
Typo in line 6 of remove_empty_lines_push_test.mjs
You have – Similar: remove_empty_lines_push_test.mjs
Should be – Similar: remove_empty_lines_filter_test.mjs
You quote the typescript interface for array like is
interface ArrayLike<T> {
length: number;
[n: number]: T;
}
But Array.from({}) works and that has neither property. I know you wrote
// If you omit .length, it is interpreted as 0
but still, Array.from({length:5}) works and returns an array of undefined values. Where is the [n: number]: T;
Thanks
@YSternlicht Arrays can have holes: https://exploringjs.com/impatient-js/ch_arrays.html#array-holes
There is a typo in the first paragraph of
28.10. Methods: iteration and transformation (.find(), .map(), .filter(), etc.)
:instead of