An IIFE (Immediately Invoked Function Expression) is an idiom in which a JavaScriptfunction runs as soon as it is defined. It is also known as a self-executing anonymous function. The name IIFE is promoted by Ben Alman in his blog
const output = iife(() => { // If headers is a Headers instance if (isHeaders(headers)) { return headers; } // If headers is an array of [key, value] pairs else if (Array.isArray(headers)) { return new Headers(headers); } // If headers is a NullableHeaders-like object (has 'values' property that is a Headers) else if ( typeof headers === "object" && headers !== null && "values" in headers && isHeaders(headers.values) ) { return headers.values; } // If headers is a plain object else if (typeof headers === "object" && headers !== null) { const entries: [string, string][] = Object.entries(headers) .filter(([, v]) => typeof v === "string") .map(([k, v]) => [k, v as string]); return new Headers(entries); } return new Headers(); });
Here, IIFE function is called with an arrow function as its parameter.