Web APIs

FormData.set()

Try the free JavaScript compiler

Replace the entries with this name by one value, or add a new entry if none exists. Example console output: ["green"].

Formal Syntax & Structure

javascript syntaxjavascript
data.set(name, value[, filename])

Parameters & Attributes

NameTypeDescription
namestringField name.
valuestring or BlobEntry value.
filenamestringFilename for Blob entries.

Return Value

undefined

No result value.

Working Example

Example Snippetjavascript
const data=new FormData(); data.append("tag","red"); data.append("tag","blue"); data.set("tag","green"); console.log(JSON.stringify(data.getAll("tag")));
JavaScript Reference