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();