Underscore's extend method as a standalone Common JS module.
Last updated 7 years ago by henrikjoreteg .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install extend-object 
SYNC missed versions from official npm registry.


underscore's extend method adapted and extracted as a standalone CommonJS module.

Note this does not shim Array.prototype.forEach so if you're in <IE8 you'll need to polyfill it. But basically any other browser will work.


var extend = require('extend-object');

var obj = {hi: 'there'};

extend(obj, {hello: 'you'});

console.log(obj); // {hi: 'there', hello: 'you'}

// it extends the first object in place
console.log(obj === extend(obj, {})); // 'true'

// you can pass as many objects as you want
extend(obj, {something: 'else'}, {other: 'item'});

// if there are conflicting keys the last one wins
extend(obj, {something: 'ok'}, {something: 'newer'});
console.log(obj.something); // 'newer'


npm install extend-object


All credit goes to Jeremy Ashkenas and the other underscore.js authors.


MIT as per underscore.

Current Tags

  • 1.0.0                                ...           latest (7 years ago)

2 Versions

  • 1.0.0                                ...           7 years ago
  • 0.1.0                                ...           7 years ago

Copyright 2014 - 2016 © taobao.org |