DOM Methods

FormData.keys()

Iterates field names in entry order, including repeated names. Use a Set if unique names are required. Use the iterator to inspect which fields are represented in a submission snapshot. It is not an array and does not provide the field values; spread it into an array or use for...of to consume it. Example result: ["tag","tag"].

Formal Syntax & Structure

html syntaxhtml
data.keys()

Return Value

iterator

Iterator yielding string field names, including duplicates.

Working Example

Example Snippethtml
<p>  Result:  <output id="result"></output></p><script>  const result = document.getElementById("result");  (async () => {  const data = new FormData();  data.append("tag", "html");  data.append("tag", "css");  result.textContent = JSON.stringify([...data.keys()]);  })().catch(error => { result.textContent = "Error: " + error.name; });</script>
HTML Reference