DUELapijlib › extend

From Botdom Documentation

< DUEL | api | jlib
Jump to: navigation, search

The function of Extend is to provide a method of easily add properties from one Object to another Oject.

Options

Extend takes two values, one optional, the other not. These are source and target. The source value is the original Object. The target value is the Object in which it has the values to extend source with.

Examples

Extending two arrays.

jLib.extend({"john": "red", "molly": "pink"}, {"fran": "purple", john:"black", "matt": "blue"});

This will return:

{
"john": "red",
"molly": "pink",
"fran": "purple",
"matt": "blue"
}


Extending jLib, using this as the target.

var nameFunc = {test: function(){
  return "test func.";
}};
jLib.extend(nameFunc);

This extends jLib with the function test, we can then call:

jLib.test();

With the results being:

test func.
Personal tools