JS Built-ins
FormDataadvanced

FormData β€” entries() iterator has Symbol.iterator

πŸ“– Usage Example
const fd = new FormData()
fd.append('x', '1')
fd.append('x', '2')
[...fd].length  // β†’ 2 (counts each entry)

Spreading FormData gives all [key, value] entries including duplicate keys.

FormData entries iterator protocol

The iterator returned by entries() implements the iterable protocol, meaning it has a Symbol.iterator method.

Challenge: Verify that typeof fd.entries()[Symbol.iterator] is 'function'.

πŸ’‘ Hints (1)
  • β€’ Iterators that also implement Symbol.iterator are called iterables β€” they can be used in for...of loops