Lodash _.create() method

Beginner
⏱️ 7 min read
📚 Updated: May 2026
🎯 3 Code examples
🚀 3 Try-it labs
Lodash

What you’ll learn

  • How _.create(prototype, [properties]) links a new object to a prototype, then copies the second-argument values onto it.
  • Why the second argument takes plain values (not property descriptors like native Object.create).
  • When to use _.create(null) for dictionary-style objects.
  • Try each example in the editor (?tryit=1, 2, 3) with Lodash from a CDN.

Prerequisites

Understand JavaScript’s prototype chain and the difference between own and inherited properties. Optional: skim _.assign() for the second-argument copy semantics.

  • Prototype chain: the [[Prototype]] slot and how lookup falls through to it.
  • Native Object.create: seeing why descriptors are noisy makes the lodash convenience obvious.

Overview

_.create is two steps in one call: link a new object to prototype, then copy own enumerable string keys from properties onto it. Use it whenever you want to skip the boilerplate of pairing Object.create with a manual Object.assign.

Prototype linkage

The new object inherits everything reachable from the prototype, including methods defined later on it.

Plain values, not descriptors

No need for { value, writable, configurable } wrappers—just pass { name: "Ada" }.

Null prototype

_.create(null) drops Object.prototype entirely—safer for user-supplied dictionary keys.

Syntax

javascript
_.create(prototype, [properties])
  • prototype: any object (including null) to become the new object’s [[Prototype]].
  • properties: optional source whose own enumerable string keys are copied (assign-like) onto the new object.
  • Returns: a brand-new object.
  • Skipped: symbol keys and inherited keys on the properties argument.
1

Factory: shared methods on the prototype

Put behavior on the prototype once, then stamp instances with their own data via the second argument.

javascript
import create from "lodash/create";

const userProto = {
  greet() {
    return "Hello, " + this.name + "!";
  }
};

function makeUser(name, age) {
  return create(userProto, { name, age });
}

const alice = makeUser("Alice", 25);
const bob   = makeUser("Bob", 30);

alice.greet();                       // "Hello, Alice!"
Object.getPrototypeOf(alice) === userProto; // true
Try it Yourself
2

Multi-level prototype chain

Layer prototypes by calling _.create at each level. Lookup walks from the instance to each parent until it finds the requested key.

javascript
import create from "lodash/create";

const mammal = { giveBirth() { return "live birth"; } };

const dog = create(mammal, {
  bark() { return "Woof!"; }
});

const labrador = create(dog, {
  breed: "Labrador",
  color: "Golden"
});

labrador.bark();        // "Woof!"        (one hop up)
labrador.giveBirth();   // "live birth"   (two hops up)
labrador.breed;         // "Labrador"     (own property)
Try it Yourself
3

Dictionary with null prototype

Pass null as the prototype to get an object with no inherited keys—safe for storing user-supplied dictionary keys like "toString" or "hasOwnProperty".

javascript
import create from "lodash/create";

const dict = create(null, { apple: 1, banana: 2 });

Object.getPrototypeOf(dict); // null
"toString" in dict;          // false — no Object.prototype noise
dict.apple;                  // 1

// Compare to a plain object:
const plain = { apple: 1 };
"toString" in plain;         // true — inherited from Object.prototype
Try it Yourself

📋 _.create vs Object.create vs _.assign

Topic_.createObject.create_.assign
Sets [[Prototype]]YesYesNo (destination unchanged)
Second-arg shapePlain object of valuesProperty descriptor mapPlain object of values
ReturnsBrand-new objectBrand-new objectThe (mutated) destination
Symbol keys copiedNoYes (via descriptors)No
Typical useFactory + initial fields in one callSame, but you control descriptorsCopy fields onto an existing object

Use _.create when you want a one-liner factory; reach for native Object.create when you need writable: false, getters, or symbol-keyed metadata.

Pitfalls to avoid

Descriptors

Confusing with Object.create

Native Object.create expects property descriptors in arg 2; lodash takes plain values. Mixing the conventions silently produces wrong shapes.

Shared state

Mutable prototype values

If the prototype holds an array or object, every instance reads the same reference. Assign instance-level state via the second argument instead.

Iteration

for...in on null-prototype objects

A _.create(null) object has no hasOwnProperty method on it—use Object.prototype.hasOwnProperty.call(obj, key) or Object.hasOwn instead of obj.hasOwnProperty(key).

❓ FAQ

Same prototype linkage, friendlier second argument. Object.create's second argument expects property descriptors (with value, writable, configurable, etc.); _.create's second argument is a plain object whose own enumerable string keys are copied onto the result.
No. Only own enumerable string-keyed properties are copied. Symbol keys and inherited keys are skipped—the same rule as _.assign.
An object with no prototype at all—perfect for dictionary-style lookups when you don't want Object.prototype methods like hasOwnProperty or toString polluting the key space.
No. The new object simply links to the prototype via its [[Prototype]] slot. Reading inherited properties walks back to the original prototype; writing to those keys creates own properties on the new object.
_.assign mutates and returns the destination, without touching its prototype. _.create returns a brand-new object whose prototype is the first argument; the second-argument values are then copied on top via assign-like semantics.
Use import create from "lodash/create"; for ESM or const create = require('lodash/create') in CommonJS.

Summary

Did you know?

_.create(proto, props) is essentially Object.create(proto) followed by _.assign(_, props). The key difference from native Object.create is that the second argument takes plain values, not property descriptors—so no { value, writable, configurable } ceremony.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful