/**
* @module objectAssign
* @description Copies all properties/keys of the specifed args and creates a new object with those properties assigned to it.
*
* @since 1.0.0
*
* @param {object} args The objects that will be used as the source of data. This function takes any number of objects as arguments. If more than one argument share the same property name, the property of the last argument will be used.
*
* @return {object} Returns a new object, with properties copied/assigned from the provided arguments.
*
* @example
* import { objectAssign } from "@gravityforms/utils";
*
* function Example() {
* const obj1 = { 'prop1' : 'val1' };
* const obj2 = {
* 'prop2' : { 'sub1' : 'subval1' },
* 'prop3' : [1, 2, 3],
* }
* const obj3 = { 'prop1' : 'val2' };
*
* const newObject = objectAssign( obj1, obj2, obj3 );
* }
*
*/
export default function() {
const resObj = {};
for ( let i = 0; i < arguments.length; i += 1 ) {
const obj = arguments[ i ];
const keys = Object.keys( obj );
for ( let j = 0; j < keys.length; j += 1 ) {
resObj[ keys[ j ] ] = obj[ keys[ j ] ];
}
}
return resObj;
}