Skip to content

Commit

Permalink
Remove a few pointless references to internal slots (#18461)
Browse files Browse the repository at this point in the history
* Remove a few pointless references to internal slots

* Update index.md

* Apply suggestions from code review

Co-authored-by: Jean-Yves Perrier <jypenator@gmail.com>

* simplify description

Co-authored-by: Jean-Yves Perrier <jypenator@gmail.com>
  • Loading branch information
Josh-Cena and teoli2003 authored Jul 18, 2022
1 parent 44dca7b commit ef59c2d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,7 @@ represented as a text value, e.g. `console.log(new Date())`, or when a date
is used in a string concatenation, such as
`const today = 'Today is ' + new Date()`.

`toString()` is a generic method, it does not require that its
`this` is a {{jsxref("Date")}} instance. However, it must have an internal
`[[TimeValue]]` property that can't be constructed using native JavaScript,
so it's effectively limited to use with {{jsxref("Date")}} instances. If called on a
non–Date instance, a {{jsxref("TypeError")}} is thrown.
`Date.prototype.toString()` must be called on {{jsxref("Date")}} instances. If the `this` value does not inherit from `Date.prototype`, a {{jsxref("TypeError")}} is thrown.

## Examples

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,32 +40,7 @@ arguments (if provided).

## Description

The `bind()` function creates a new **bound function**, which
is an _exotic function object_ (a term from ECMAScript 2015) that wraps the
original function object. Calling the bound function generally results in the execution
of its wrapped function.

A bound function has the following internal properties:

- **`[[BoundTargetFunction]]`**
- : The wrapped function object.
- **`[[BoundThis]]`**
- : The value that is always passed as `this` value when calling the wrapped
function.
- **`[[BoundArguments]]`**
- : A list of values whose elements are used as the first arguments to any call to the
wrapped function.
- **`[[Call]]`**
- : Executes code associated with this object. Invoked via a function call expression.
The arguments to the internal method are a `this` value and a list
containing the arguments passed to the function by a call expression.

When a bound function is called, it calls internal method `[[Call]]` on
`[[BoundTargetFunction]]`, with following arguments
`Call(boundThis, ...args)`. Where
`boundThis` is `[[BoundThis]]`,
`args` is `[[BoundArguments]]`, followed by the
arguments passed by the function call.
The `bind()` function creates a new **bound function**. Calling the bound function generally results in the execution of its wrapped function. The bound function will store the parameters passed — which include the value of `this` and the first few arguments — as its internal state. These values are stored in advance, instead of being passed at call time. You can generally see `const boundFn = fn.bind(thisArg, arg1, arg2)` as being equivalent to `const boundFn = (...restArgs) => fn.call(thisArg, arg1, arg2, ...restArgs)`.

A bound function may also be constructed using the {{jsxref("Operators/new", "new")}}
operator. Doing so acts as though the target function had instead been constructed. The
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,12 @@ returned.
## Description

In contrast to `Symbol()`, the `Symbol.for()` function creates a
symbol available in a global symbol registry list. `Symbol.for()` does also
symbol available in a [global symbol registry](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol#shared_symbols_in_the_global_symbol_registry) list. `Symbol.for()` does also
not necessarily create a new symbol on every call, but checks first if a symbol with the
given `key` is already present in the registry. In that case, that symbol is
returned. If no symbol with the given key is found, `Symbol.for()` will
create a new global symbol.

### Global symbol registry

The global symbol registry is a list with the following record structure and it is
initialized empty:

| Field name | Value |
| ---------- | --------------------------------------- |
| [[key]] | A string key used to identify a symbol. |
| [[symbol]] | A symbol that is stored globally. |

## Examples

### Using Symbol.for()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ Symbol.keyFor(sym);

### Return value

A string representing the key for the given symbol if one is found on the global
registry; otherwise, {{jsxref("undefined")}}.
A string representing the key for the given symbol if one is found on the [global registry](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol#shared_symbols_in_the_global_symbol_registry); otherwise, {{jsxref("undefined")}}.

## Examples

Expand Down

0 comments on commit ef59c2d

Please sign in to comment.