Stage 1 Draft / June 24, 2020

Slice notation

1 Well-Known Symbols

Well-known symbols are built-in Symbol values that are explicitly referenced by algorithms of this specification. They are typically used as the keys of properties whose values serve as extension points of a specification algorithm. Unless otherwise specified, well-known symbols values are shared by all realms (8.2).

Within this specification a well-known symbol is referred to by using a notation of the form @@name, where “name” is one of the values listed in Table 1.

Table 1: Well-known Symbols
Specification Name [[Description]] Value and Purpose
@@slice "Symbol.slice" A method that slices the receiver based on a start and end index.

2 Properties of the Symbol Constructor

2.1 Symbol.slice

The initial value of Symbol.slice is the well known symbol @@slice (Table 1).

This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.

3 Properties of the Array Prototype

3.1 Array.prototype [ @@slice ] (start, end)

The initial value of the @@slice property is the same function object as the initial value of the Array.prototype.slice property.

4 Properties of the %TypedArray.prototype% Object

4.1 %TypedArray%.prototype [ @@slice ] (start, end)

The initial value of the @@slice property is the same function object as the initial value of the %TypedArray%.prototype.slice property.

5 Properties of the ArrayBuffer Prototype Object

5.1 ArrayBuffer.prototype [ @@slice ] (start, end)

The initial value of the @@slice property is the same function object as the initial value of the ArrayBuffer.prototype.slice property.

6 Properties of the SharedArrayBuffer Prototype Object

6.1 SharedArrayBuffer.prototype [ @@slice ] (start, end)

The initial value of the @@slice property is the same function object as the initial value of the SharedArrayBuffer.prototype.slice property.

7 Left-Hand-Side Expressions

Syntax

MemberExpression[Yield, Await]:PrimaryExpression[?Yield, ?Await] MemberExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] MemberExpression[?Yield, ?Await].IdentifierName MemberExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] SuperProperty[?Yield, ?Await] MetaProperty newMemberExpression[?Yield, ?Await]Arguments[?Yield, ?Await] MemberExpression[?Yield, ?Await][AssignmentExpression[+In, ?Yield, ?Await]opt:AssignmentExpression[+In, ?Yield, ?Await]opt] CallExpression[Yield, Await]:CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] SuperCall[?Yield, ?Await] ImportCall[?Yield, ?Await] CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] CallExpression[?Yield, ?Await].IdentifierName CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await, +Tagged] CallExpression[?Yield, ?Await][AssignmentExpression[+In, ?Yield, ?Await]opt:AssignmentExpression[+In, ?Yield, ?Await]opt] OptionalExpression[Yield, Await]:MemberExpression[?Yield, ?Await]OptionalChain[?Yield, ?Await] CallExpression[?Yield, ?Await]OptionalChain[?Yield, ?Await] OptionalExpression[?Yield, ?Await]OptionalChain[?Yield, ?Await] OptionalChain[Yield, Await]:?.[Expression[+In, ?Yield, ?Await]] ?.IdentifierName ?.Arguments[?Yield, ?Await] ?.TemplateLiteral[?Yield, ?Await, +Tagged] ?.[AssignmentExpression[+In, ?Yield, ?Await]opt:AssignmentExpression[+In, ?Yield, ?Await]opt] OptionalChain[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] OptionalChain[?Yield, ?Await].IdentifierName OptionalChain[?Yield, ?Await]Arguments[?Yield, ?Await] OptionalChain[?Yield, ?Await]TemplateLiteral[?Yield, ?Await, +Tagged] OptionalChain[?Yield, ?Await][AssignmentExpression[+In, ?Yield, ?Await]opt:AssignmentExpression[+In, ?Yield, ?Await]opt]

7.1 Static Semantics: AssignmentTargetType

MemberExpression:MemberExpression[AssignmentExpressionopt:AssignmentExpressionopt] CallExpression:CallExpression[AssignmentExpressionopt:AssignmentExpressionopt]
  1. Return invalid.

7.2 Runtime Semantics

7.2.1 Runtime Semantics: EvaluateSliceNotation ( baseValue, startExpression, endExpression )

The abstract operation EvaluateSliceNotation takes as arguments a baseValue (an ECMAScript langauge value), startExpression (a Parse Node), and endExpression (a Parse Node). It performs the following steps:

  1. If the startExpression is present, then
    1. Let startRef be the result of evaluating the startExpression.
    2. Let start be ? GetValue(startRef).
  2. Else,
    1. Let start be 0.
  3. If the endExpression is present, then
    1. Let endRef be the result of evaluating the endExpression.
    2. Let end be ? GetValue(endRef).
  4. Else,
    1. Let end be undefined.
  5. Let base be ? ToObject(baseValue).
  6. Let method be ? GetMethod(base, @@slice).
  7. Return ? Call(method, base, « start, end »).

7.2.2 Runtime Semantics: Evaluation

MemberExpression:MemberExpression[AssignmentExpressionopt:AssignmentExpressionopt]
  1. Let baseReference be the result of evaluating MemberExpression.
  2. Let baseValue be ? GetValue(baseReference).
  3. Let startExpression be the first AssignmentExpression.
  4. Let endExpression be the second AssignmentExpression.
  5. Return ? EvaluateSliceNotation(baseReference, startExpression, endExpression).
CallExpression:CallExpression[AssignmentExpressionopt:AssignmentExpressionopt]
  1. Let baseReference be the result of evaluating CallExpression.
  2. Let baseValue be ? GetValue(baseReference).
  3. Let startExpression be the first AssignmentExpression.
  4. Let endExpression be the second AssignmentExpression.
  5. Return ? EvaluateSliceNotation(baseValue, startExpression, endExpression).

7.2.3 Runtime Semantics: ChainEvaluation

With parameters baseValue and baseReference.

OptionalChain:?.[AssignmentExpressionopt:AssignmentExpressionopt]
  1. Let startExpression be the first AssignmentExpression.
  2. Let endExpression be the second AssignmentExpression.
  3. Return ? EvaluateSliceNotation(baseValue, startExpression, endExpression).
OptionalChain:OptionalChain[AssignmentExpressionopt:AssignmentExpressionopt]
  1. Let optionalChain be OptionalChain.
  2. Let newBaseReference be ? ChainEvaluation of optionalChain with arguments baseValue and baseReference.
  3. Let newBaseValue be ? GetValue(newBaseReference).
  4. Let startExpression be the first AssignmentExpression.
  5. Let endExpression be the second AssignmentExpression.
  6. Return ? EvaluateSliceNotation(newBaseValue, startExpression, endExpression).