FormData

noun

say it: “FORM DAT-uh” /fɔːrm ˈdætə/ or “FORM DAY-tuh” /fɔːrm ˈdeɪtə/

A built-in JavaScript object that gathers every named field of a form in one step, so you can read each answer by its name.

What is FormData in JavaScript?

FormData — A built-in object that gathers every field of a form that has a name, in one step. new FormData(form) reads them, and get('title') gives one field's value, always as text, so turn a number box's value into a number yourself.

const form = document.querySelector('#add-book');
const data = new FormData(form);
console.log(data.get('title')); // what the visitor typed in the title box

In a sentence

  • “FormData left out the phone box because I forgot to give it a name.”
  • “I made a FormData object from the sign-up form and read the email with get('email').”

Level: Apprentice · More JavaScript terms at this level

Updated