7.3. Convert a key to a value
To convert a key to a value with key, run the following steps. The steps return an ECMAScript value.
Let type be key’s type.
Let value be key’s value.
Switch on type:
number
Return an ECMAScript Number value equal to value
string
Return an ECMAScript String value equal to value
date
Let date be the result of executing the ECMAScript Date constructor with the single argument value.
Assert: date is not an abrupt completion.
Return date.
*binary*
1. Let len be value’s [length](https://infra.spec.whatwg.org/#byte-sequence-length).
2. Let buffer be the result of executing the ECMAScript ArrayBuffer constructor with len.
3. [Assert](https://infra.spec.whatwg.org/#assert): buffer is not an [abrupt completion](https://tc39.github.io/ecma262/#sec-completion-record-specification-type).
4. Set the entries in buffer’s \[\[ArrayBufferData\]\] internal slot to the entries in value.
5. Return buffer.
*array*
1. Let array be the result of executing the ECMAScript Array constructor with no arguments.
2. [Assert](https://infra.spec.whatwg.org/#assert): array is not an [abrupt completion](https://tc39.github.io/ecma262/#sec-completion-record-specification-type).
3. Let len be value’s [size](https://infra.spec.whatwg.org/#list-size).
4. Let index be 0.
5. While index is less than len:
1. Let entry be the result of running [convert a key to a value](#convert-a-key-to-a-value) with value\[index\].
2. Let status be [CreateDataProperty](https://tc39.github.io/ecma262/#sec-createdataproperty)(array, index, entry).
3. [Assert](https://infra.spec.whatwg.org/#assert): status is true.
4. Increase index by 1.
6. Return array.