简体   繁体   中英

How to extend object in gulp without installing npm

How to extend object in gulp without installing npm?

var a = {a: 1};
var b = {b: 2};
var c = extend({}, a, b, {c:3});

c is {a: 1, b: 2, c: 3}

Not that I know of. I would recommend that you use object-assign , a forward compatible module that will delegate to the ES6 Object.assign if available. It's extremely lightweight at 26 lines (as of this writing).

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

var a = {a: 1};
var b = {b: 2};
var c = assign(a, b, {c:3});

console.log(c);

// => {a: 1, b: 2, c: 3}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM