tc39 / proposal-slice-notation

http://tc39.es/proposal-slice-notation/
MIT License
523 stars 18 forks source link

What does indexing into an object with the proposed slice notation do #9

Closed benderTheCrime closed 4 years ago

benderTheCrime commented 6 years ago

Example:


// Create an "arguments"-like object here, but any Object will do.
const obj = {
    1: 'foo',
    2: 'bar',
};

const bar = obj[:2];

Should this be considered a syntax error?

ljharb commented 6 years ago

It doesn't have a length, so its length would ToLength to 0, so bar should be [] - just like Array.prototype.slice.call(obj, 0, 2) would produce.