FormData

FormData.prototype.get

Returns the first value associated with a given key from within a FormData object

Syntax

JavaScript
formData.get(name)

Parameters

ParameterTypeDescription
namestringThe name of the key to retrieve

Return Value

The value for the key, or null if the key does not exist

Examples

Basic Usage
const fd = new FormData()
fd.append('name', 'Alice')
console.log(fd.get('name')) // 'Alice'
Practical Example
const form = document.querySelector('form') as HTMLFormElement
const fd = new FormData(form)
const email = fd.get('email')
console.log('Email:', email)
Advanced Usage
function getFormValues(form: HTMLFormElement) {
  const fd = new FormData(form)
  return Object.fromEntries(fd.entries())
}

Understanding FormData.prototype.get

The FormData.prototype.get method in JavaScript returns the first value associated with a given key from within a FormData object. It belongs to the FormData object and is one of the most widely used methods for working with formdata values in modern JavaScript and TypeScript applications.

The method signature is formData.get(name). It accepts 1 parameter: name. When called, it returns the value for the key, or null if the key does not exist. Understanding when and how to use get() helps you write more expressive, readable code.

Common use cases for FormData.prototype.get include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like fetch-formdata-getall, fetch-formdata-set, fetch-formdata-append, enabling you to chain operations together for complex data manipulation pipelines.

Browser support for FormData.prototype.get is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.

Browser Compatibility

Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.

Related Methods

More FormData Methods

Other methods in the FormData object

Related Tools

More FormData Methods

Explore JavaScript Methods

Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.