Modules

filter

 

Objects/Functions

module (N/util)

SuiteScript 2.0

util.extend(receiver, contributor)

// Please search https://system.netsuite.com/app/help/helpcenter.nl?search=util.extend(receiver, contributor) for more information.

N/util Module
util.extend(receiver, contributor)
Method Description: Copies the properties in a source object to a destination object. You can use this method to merge two objects.
Returns: The destination object.
Supported Script Types: All script types For more information, see SuiteScript 2.0 Script Types.
Governance: None
Module: N/util Module
Since: 2016.1
Search NetSuite - https://system.netsuite.com/app/help/helpcenter.nl?search=util.extend(receiver, contributor)

Example:

// Code Example 1
//Add additional code
//...
var colors = {};
var firstSet = {'color1':'red',
'color2':'yellow',
'color3':'blue'};
var secondSet = {'color4':'green',
'color5':'orange',
'color6':'violet'
};

// Extends colors object with the information in firstSet
// Colors will get {'color1':'red','color2':'yellow','color3':'blue'}
util.extend(colors, firstSet);

// Extends colors object with the information in secondSet
// Colors will get {'color1':'red','color2':'yellow','color3':'blue','color4':'green','color5':'orange','color6':'violet'}
util.extend(colors, secondSet);
});
//...
//Add additional code

// Code Example 2
//Add additional code
//...
var colors = {};
var firstSet = {'color1':'red',
'color2':'yellow',
'color3':'blue'
};
var secondSet = {'color2':'green',
'color3':'orange',
'color4':'violet'
};

// Extends colors object with the information in firstSet
// Colors will get {'color1':'red','color2':'yellow','color3':'blue'}
util.extend(colors, firstSet);

// Extends colors object with the information in secondSet and overrides the value if there are similar keys
// Colors will get {'color1':'red','color2':'green','color3':'orange','color4':'violet'}
util.extend(colors, secondSet);

var x = 0;
});
//...
//Add additional code

//SOURCE: https://system.netsuite.com/app/help/helpcenter.nl?fid=section_4541702994.html