DOM Methods
FormData.forEach()
Calls a callback for each entry with value, name and the FormData object, in that order. Duplicate names remain separate. Do not assume an asynchronous callback will be awaited. Example result: tag:html, tag:css.
Formal Syntax & Structure
html syntaxhtml
data.forEach(callback, thisArg?)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| callback | function | Receives value, name and FormData. |
| thisArg | any | Optional callback this value. |
Return Value
undefined
No return value.
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"); const items = []; data.forEach((value, name) => items.push(name + ":" + value)); result.textContent = items.join(", "); })().catch(error => { result.textContent = "Error: " + error.name; });</script>