Skip to main content

mixin

_.mixin(object) # Ⓢ [Ⓣ][1] Ⓝ

Adds all own enumerable string keyed function properties of a source



object to the destination object. If object is a function, then methods



are added to its prototype as well.





Note: Use _.runInContext to create a pristine lodash function to



avoid conflicts caused by modifying the original.

Since​

0.1.0

Arguments​

  1. object (Function|Object): The destination object.

Returns​

(*): Returns object.

Example​

function vowels(string) {
return _.filter(function(v) {
return /[aeiou]/i.test(v);
}, string);
}

_.mixin({ 'vowels': vowels });
_.vowels('fred');
// => ['e']

_('fred').vowels().value();
// => ['e']

_.mixin([{ 'vowels': vowels }, { 'chain': false }]);
_('fred').vowels();
// => ['e']