- Lodash Tutorial
- Lodash - Home
- Lodash - Overview
- Lodash - Environment Setup
- Lodash - Array
- Lodash - Collection
- Lodash - Date
- Lodash - Function
- Lodash - Lang
- Lodash - Math
- Lodash - Number
- Lodash - Object
- Lodash - Seq
- Lodash - String
- Lodash - Util
- Lodash - Properties
- Lodash - Methods
- Lodash Useful Resources
- Lodash - Quick Guide
- Lodash - Useful Resources
- Lodash - Discussion
Lodash - mixin method
Syntax
_.mixin([object=lodash], source, [options={}])
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.
Arguments
[object=lodash] (Function|Object) − The destination object.
source (Object) − The object of functions to add.
[options={}] (Object) − The options object.
[options.chain=true] (boolean) − Specify whether mixins are chainable.
Output
(Function) − Returns object.
Example
var _ = require('lodash'); function vowels(string) { return _.filter(string, function(v) { return /[aeiou]/i.test(v); }); } _.mixin({ 'vowels': vowels }, { 'chain': false }); console.log(_('Julie').vowels());
Save the above program in tester.js. Run the following command to execute this program.
Command
\>node tester.js
Output
[ 'u', 'i', 'e' ]
lodash_util.htm
Advertisements