Skip to content
This repository was archived by the owner on Dec 28, 2017. It is now read-only.

Latest commit

 

History

History
28 lines (21 loc) · 1.1 KB

File metadata and controls

28 lines (21 loc) · 1.1 KB

Map.prototype.toJSON ( )

This function provides an Array representation of an iterable object for use by JSON.stringify (24.3.2).

When the toJSON method is called, the following steps are taken:

  1. Let M be the this value.
  2. Let iterator be ? GetIterator(M)
  3. Let A be ! ArrayCreate(0).
  4. Let k be 0.
  5. Repeat
  6. Let Pk be ! ToString(k).
  7. Let next be ? IteratorStep(iterator).
  8. If next is false, then 1. Perform ? Set(A, "length", k, true). 1. Return A.
  9. Let nextValue be ? IteratorValue(next).
  10. Let defineStatus be CreateDataPropertyOrThrow(A, Pk, nextValue).
  11. If defineStatus is an abrupt completion, return IteratorClose(iterator, defineStatus).
  12. Increase k by 1.

The length property of the toJSON method is 0.

Set.prototype.toJSON ( )

The initial value of the toJSON property is the same function object as the initial value of the Map.prototype.toJSON property.