Skip to main content

stubObject()

stubObject(): object

Returns an empty object.

DEPRECATED

Use an inline arrow function () => ({}) instead.


Returns: objectโ€‹

An empty object.


Sinceโ€‹

2.0.0


Also known asโ€‹

stubObject (Lodash, es-toolkit) ยท โŒ (Remeda, Radashi, Ramda, Effect, Modern Dash, Antfu)


Exampleโ€‹

// โŒ Deprecated approach
stubObject(); // => {}

// โœ… Recommended approach
(() => ({}))(); // => {}

How it works?โ€‹

Returns an empty object. Deprecated: Use () => ({}) directly.

Native Equivalentโ€‹

// โŒ stubObject
// โœ… () => ({})

Use Casesโ€‹

Return empty object ๐Ÿ“Œโ€‹

Return empty object as default.

const getDefaults = () => ({});

Initialize stateโ€‹

Create empty initial state.

const createState = () => ({});
const state = createState();