SlideShare une entreprise Scribd logo
1  sur  20
Télécharger pour lire hors ligne
Lodash js
Jason
lodash js
Array
Chain
Collection
Function
Lang
Math
Number
Object
String
Utility
Methods
Properties
_(value)
.Creates a lodash object which wraps value to enable implicit chaining.
.Methods that operate on and return arrays, collections, and functions can be
chained together.
.Methods that return a boolean or single value will automatically end the chain
returning the unwrapped value
.The chainable wrapper methods are : filter, sort, sortBy...etc
.The wrapper methods that are not chainable by default are : first, sum, trim...etc
_(value)
var wrapped = _([1, 2, 3]);
// returns an unwrapped value
wrapped.reduce(function(sum, n) {
return sum + n;
});
// → 6
// returns a wrapped value
var squares = wrapped.map(function(n) {
return n * n;
});
_.isArray(squares);
// → false
_.isArray(squares.value());
// → true
_.chain(value)
.Creates a lodash object that wraps value with explicit method chaining
enabled.
.Arguments value (*): The value to wrap.
.Returns:(Object): Returns the new lodash wrapper instance.
_.chain(value)
var users = [
{ 'user': 'barney', 'age': 36 },
{ 'user': 'fred', 'age': 40 },
{ 'user': 'pebbles', 'age': 1 }
];
var youngest = _.chain(users)
.sortBy('age')
.map(function(chr) {
return chr.user + ' is ' + chr.age;
})
.first()
.value();
// → 'pebbles is 1'
_.tap
.This method invokes interceptor
and returns value.
. _tap(value, interceptor, [thisArg])
.Returns:(*): Returns value.
_([1, 2, 3]).tap(function(array) {
array.pop();
})
.reverse()
.value();
// → [2, 1]
_.thru
.This method is like _.tap except
that it returns the result of interceptor.
. _thru(value, interceptor, [thisArg])
.Returns:(*): Returns the result of interceptor
_(' abc ')
.chain()
.trim()
.thru(function(value) {
return [value];
})
.value();
// → ['abc']
_.flatten
.Flattens a nested array.
. _flatten(array, [isDeep])
.Returns:(Array): Returns the new flattened array.
_.flatten([1, [2, 3, [4]]]);
// → [1, 2, 3, [4]]
// using isDeep
_.flatten([1, [2, 3, [4]]], true);
// → [1, 2, 3, 4]
_intersection
.Creates an array of unique values in
all provided arrays.
. _intersection(array)
.Returns:(Array): Returns the new array of shared
values.
_.intersection([1, 2], [4, 2], [2, 1]);
// → [2]
_.xor
.Creates an array that is the symmetric difference
of the provided arrays.
. _.xor(array)
.Returns:(Array): Returns the new array of values.
_.xor([1, 2], [4, 2]);
// → [1, 4]
_.pluck
.Gets the value of key from all elements
in collection.
._.pluck(collection, key)
.Returns:(Array): Returns the property values
var users = [
{ 'user': 'barney', 'age': 36 },
{ 'user': 'fred', 'age': 40 }
];
_.pluck(users, 'user');
// → ['barney', 'fred']
_where
.Performs a deep comparison between each element in collection and the source object,
returning an array of all elements that have equivalent property values.
._.where(collection, source)
.Returns:(Array): Returns the new filtered array.
var users = [
{ 'user': 'barney', 'age': 36, 'active': false, 'pets': ['hoppy'] },
{ 'user': 'fred', 'age': 40, 'active': true, 'pets': ['baby puss', 'dino'] }
];
_.pluck(_.where(users, { 'age': 36, 'active': false }), 'user');
// → ['barney']
_.uniqueId
.Generates a unique ID. If prefix is provided the ID
is appended to it.
._.uniqueId([prefix])
.Returns:(string): Returns the unique ID.
_.uniqueId('contact_');
// → 'contact_104'
_.uniqueId();
// → '105'
_.curry
.Creates a function that accepts one or more
arguments of func that when called either invokes
func returning its result
._.curry(func, [arity=func.length])
.Returns:(Function): Returns the new curried function.
var abc = function(a, b, c) {
return [a, b, c];
};
var curried = _.curry(abc);
curried(1)(2)(3);
// → [1, 2, 3]
curried(1, 2)(3);
// → [1, 2, 3]
curried(1)(_, 3)(2);
// → [1, 2, 3]
_.bind
.Creates a function that invokes func with the this binding of
thisArg and prepends any additional _.bind arguments to
those provided to the bound function.
._.bind(func, thisArg, [partials])
.Returns:(Function): Returns the new bound function.
var greet = function(greeting, punctuation) {
return greeting + ' ' + this.user + punctuation;
};
var object = { 'user': 'fred' };
var bound = _.bind(greet, object, 'hi');
bound('!');
// → 'hi fred!'
// using placeholders
var bound = _.bind(greet, object, _, '!');
bound('hi');
// → 'hi fred!'
_.bindAll
.Binds methods of an object to the object itself, overwriting
the existing method. Method names may be specified as
individual arguments or as arrays of method names.
._.bindAll(object, [methodNames])
.Returns:(Object): Returns object.
var view = {
'label': 'docs',
'onClick': function() {
console.log('clicked ' + this.label);
}
};
_.bindAll(view);
$('#docs').on('click', view.onClick);
// → logs 'clicked docs' when the element
is clicked
_.get
.Gets the property value of path on object. If the resolved
value is undefined the defaultValue is used in its place.
._.get(object, path, [defaultValue])
.Returns:Returns the resolved Value.
var object = { 'a': [{ 'b': { 'c': 3 } }] };
_.get(object, 'a[0].b.c');
// → 3
_.get(object, ['a', '0', 'b', 'c']);
// → 3
_.get(object, 'a.b.c', 'default');
// → 'default'
_template
var compiled = _.template('hello <%= user %>!');
compiled({ 'user': 'fred' });
// → 'hello fred!'
var compiled = _.template('<b><%- value %></b>');
compiled({ 'value': '<script>' });
// → '<b>&lt;script&gt;</b>'
var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
compiled({ 'users': ['fred', 'barney'] });
// → '<li>fred</li><li>barney</li>'
var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
compiled({ 'users': ['fred', 'barney'] });
// → '<li>fred</li><li>barney</li>'
Reference
API Documentaion : https://lodash.com/docs
DevDocs: http://devdocs.io/lodash/

Contenu connexe

Tendances

11. session 11 functions and objects
11. session 11   functions and objects11. session 11   functions and objects
11. session 11 functions and objects
Phúc Đỗ
 
Symfony2 and Doctrine2 Integration
Symfony2 and Doctrine2 IntegrationSymfony2 and Doctrine2 Integration
Symfony2 and Doctrine2 Integration
Jonathan Wage
 

Tendances (20)

Introducing CakeEntity
Introducing CakeEntityIntroducing CakeEntity
Introducing CakeEntity
 
11. session 11 functions and objects
11. session 11   functions and objects11. session 11   functions and objects
11. session 11 functions and objects
 
Drupal 8 database api
Drupal 8 database apiDrupal 8 database api
Drupal 8 database api
 
Symfony2 and Doctrine2 Integration
Symfony2 and Doctrine2 IntegrationSymfony2 and Doctrine2 Integration
Symfony2 and Doctrine2 Integration
 
How te bring common UI patterns to ADF
How te bring common UI patterns to ADFHow te bring common UI patterns to ADF
How te bring common UI patterns to ADF
 
Beyond the DOM: Sane Structure for JS Apps
Beyond the DOM: Sane Structure for JS AppsBeyond the DOM: Sane Structure for JS Apps
Beyond the DOM: Sane Structure for JS Apps
 
Intro programacion funcional
Intro programacion funcionalIntro programacion funcional
Intro programacion funcional
 
Scala introduction
Scala introductionScala introduction
Scala introduction
 
Variables, expressions, standard types
 Variables, expressions, standard types  Variables, expressions, standard types
Variables, expressions, standard types
 
Introducing CakeEntity
Introducing CakeEntityIntroducing CakeEntity
Introducing CakeEntity
 
Implementing a many-to-many Relationship with Slick
Implementing a many-to-many Relationship with SlickImplementing a many-to-many Relationship with Slick
Implementing a many-to-many Relationship with Slick
 
JQuery Presentation
JQuery PresentationJQuery Presentation
JQuery Presentation
 
Drupal7 dbtng
Drupal7  dbtngDrupal7  dbtng
Drupal7 dbtng
 
CakeFest 2013 keynote
CakeFest 2013 keynoteCakeFest 2013 keynote
CakeFest 2013 keynote
 
Js types
Js typesJs types
Js types
 
ActionScript3 collection query API proposal
ActionScript3 collection query API proposalActionScript3 collection query API proposal
ActionScript3 collection query API proposal
 
Selectors and normalizing state shape
Selectors and normalizing state shapeSelectors and normalizing state shape
Selectors and normalizing state shape
 
Into Clojure
Into ClojureInto Clojure
Into Clojure
 
How to Bring Common UI Patterns to ADF
How to Bring Common UI Patterns to ADF How to Bring Common UI Patterns to ADF
How to Bring Common UI Patterns to ADF
 
Indexing thousands of writes per second with redis
Indexing thousands of writes per second with redisIndexing thousands of writes per second with redis
Indexing thousands of writes per second with redis
 

Similaire à Lodash js

Underscore.js
Underscore.jsUnderscore.js
Underscore.js
timourian
 
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
Dmitry Soshnikov
 
RubyMiniGuide-v1.0_0
RubyMiniGuide-v1.0_0RubyMiniGuide-v1.0_0
RubyMiniGuide-v1.0_0
tutorialsruby
 
RubyMiniGuide-v1.0_0
RubyMiniGuide-v1.0_0RubyMiniGuide-v1.0_0
RubyMiniGuide-v1.0_0
tutorialsruby
 
APPLICATION TO DOCUMENT ALL THE DETAILS OF JAVA CLASSES OF A PROJECT AT ONCE...
APPLICATION TO DOCUMENT ALL THE  DETAILS OF JAVA CLASSES OF A PROJECT AT ONCE...APPLICATION TO DOCUMENT ALL THE  DETAILS OF JAVA CLASSES OF A PROJECT AT ONCE...
APPLICATION TO DOCUMENT ALL THE DETAILS OF JAVA CLASSES OF A PROJECT AT ONCE...
DEEPANSHU GUPTA
 
Zepto.js, a jQuery-compatible mobile JavaScript framework in 2K
Zepto.js, a jQuery-compatible mobile JavaScript framework in 2KZepto.js, a jQuery-compatible mobile JavaScript framework in 2K
Zepto.js, a jQuery-compatible mobile JavaScript framework in 2K
Thomas Fuchs
 

Similaire à Lodash js (20)

Underscore.js
Underscore.jsUnderscore.js
Underscore.js
 
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
 
RubyMiniGuide-v1.0_0
RubyMiniGuide-v1.0_0RubyMiniGuide-v1.0_0
RubyMiniGuide-v1.0_0
 
RubyMiniGuide-v1.0_0
RubyMiniGuide-v1.0_0RubyMiniGuide-v1.0_0
RubyMiniGuide-v1.0_0
 
25-functions.ppt
25-functions.ppt25-functions.ppt
25-functions.ppt
 
7 Habits For a More Functional Swift
7 Habits For a More Functional Swift7 Habits For a More Functional Swift
7 Habits For a More Functional Swift
 
Object Oriented JavaScript
Object Oriented JavaScriptObject Oriented JavaScript
Object Oriented JavaScript
 
The JavaScript Programming Language
The JavaScript Programming LanguageThe JavaScript Programming Language
The JavaScript Programming Language
 
Array properties
Array propertiesArray properties
Array properties
 
What are arrays in java script
What are arrays in java scriptWhat are arrays in java script
What are arrays in java script
 
Recursion Lecture in Java
Recursion Lecture in JavaRecursion Lecture in Java
Recursion Lecture in Java
 
Extractors & Implicit conversions
Extractors & Implicit conversionsExtractors & Implicit conversions
Extractors & Implicit conversions
 
APPLICATION TO DOCUMENT ALL THE DETAILS OF JAVA CLASSES OF A PROJECT AT ONCE...
APPLICATION TO DOCUMENT ALL THE  DETAILS OF JAVA CLASSES OF A PROJECT AT ONCE...APPLICATION TO DOCUMENT ALL THE  DETAILS OF JAVA CLASSES OF A PROJECT AT ONCE...
APPLICATION TO DOCUMENT ALL THE DETAILS OF JAVA CLASSES OF A PROJECT AT ONCE...
 
8558537werr.pptx
8558537werr.pptx8558537werr.pptx
8558537werr.pptx
 
Java script arrays
Java script arraysJava script arrays
Java script arrays
 
Java script arrays
Java script arraysJava script arrays
Java script arrays
 
Zepto.js, a jQuery-compatible mobile JavaScript framework in 2K
Zepto.js, a jQuery-compatible mobile JavaScript framework in 2KZepto.js, a jQuery-compatible mobile JavaScript framework in 2K
Zepto.js, a jQuery-compatible mobile JavaScript framework in 2K
 
JS OO and Closures
JS OO and ClosuresJS OO and Closures
JS OO and Closures
 
Underscore and Backbone Models
Underscore and Backbone ModelsUnderscore and Backbone Models
Underscore and Backbone Models
 
Prototype Framework
Prototype FrameworkPrototype Framework
Prototype Framework
 

Plus de LearningTech (20)

vim
vimvim
vim
 
PostCss
PostCssPostCss
PostCss
 
ReactJs
ReactJsReactJs
ReactJs
 
Docker
DockerDocker
Docker
 
Semantic ui
Semantic uiSemantic ui
Semantic ui
 
node.js errors
node.js errorsnode.js errors
node.js errors
 
Process control nodejs
Process control nodejsProcess control nodejs
Process control nodejs
 
Expression tree
Expression treeExpression tree
Expression tree
 
SQL 效能調校
SQL 效能調校SQL 效能調校
SQL 效能調校
 
flexbox report
flexbox reportflexbox report
flexbox report
 
Vic weekly learning_20160504
Vic weekly learning_20160504Vic weekly learning_20160504
Vic weekly learning_20160504
 
Reflection &amp; activator
Reflection &amp; activatorReflection &amp; activator
Reflection &amp; activator
 
Peggy markdown
Peggy markdownPeggy markdown
Peggy markdown
 
Node child process
Node child processNode child process
Node child process
 
20160415ken.lee
20160415ken.lee20160415ken.lee
20160415ken.lee
 
Peggy elasticsearch應用
Peggy elasticsearch應用Peggy elasticsearch應用
Peggy elasticsearch應用
 
Expression tree
Expression treeExpression tree
Expression tree
 
Vic weekly learning_20160325
Vic weekly learning_20160325Vic weekly learning_20160325
Vic weekly learning_20160325
 
D3js learning tips
D3js learning tipsD3js learning tips
D3js learning tips
 
git command
git commandgit command
git command
 

Dernier

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Dernier (20)

Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 

Lodash js

  • 3. _(value) .Creates a lodash object which wraps value to enable implicit chaining. .Methods that operate on and return arrays, collections, and functions can be chained together. .Methods that return a boolean or single value will automatically end the chain returning the unwrapped value .The chainable wrapper methods are : filter, sort, sortBy...etc .The wrapper methods that are not chainable by default are : first, sum, trim...etc
  • 4. _(value) var wrapped = _([1, 2, 3]); // returns an unwrapped value wrapped.reduce(function(sum, n) { return sum + n; }); // → 6 // returns a wrapped value var squares = wrapped.map(function(n) { return n * n; }); _.isArray(squares); // → false _.isArray(squares.value()); // → true
  • 5. _.chain(value) .Creates a lodash object that wraps value with explicit method chaining enabled. .Arguments value (*): The value to wrap. .Returns:(Object): Returns the new lodash wrapper instance.
  • 6. _.chain(value) var users = [ { 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }, { 'user': 'pebbles', 'age': 1 } ]; var youngest = _.chain(users) .sortBy('age') .map(function(chr) { return chr.user + ' is ' + chr.age; }) .first() .value(); // → 'pebbles is 1'
  • 7. _.tap .This method invokes interceptor and returns value. . _tap(value, interceptor, [thisArg]) .Returns:(*): Returns value. _([1, 2, 3]).tap(function(array) { array.pop(); }) .reverse() .value(); // → [2, 1]
  • 8. _.thru .This method is like _.tap except that it returns the result of interceptor. . _thru(value, interceptor, [thisArg]) .Returns:(*): Returns the result of interceptor _(' abc ') .chain() .trim() .thru(function(value) { return [value]; }) .value(); // → ['abc']
  • 9. _.flatten .Flattens a nested array. . _flatten(array, [isDeep]) .Returns:(Array): Returns the new flattened array. _.flatten([1, [2, 3, [4]]]); // → [1, 2, 3, [4]] // using isDeep _.flatten([1, [2, 3, [4]]], true); // → [1, 2, 3, 4]
  • 10. _intersection .Creates an array of unique values in all provided arrays. . _intersection(array) .Returns:(Array): Returns the new array of shared values. _.intersection([1, 2], [4, 2], [2, 1]); // → [2]
  • 11. _.xor .Creates an array that is the symmetric difference of the provided arrays. . _.xor(array) .Returns:(Array): Returns the new array of values. _.xor([1, 2], [4, 2]); // → [1, 4]
  • 12. _.pluck .Gets the value of key from all elements in collection. ._.pluck(collection, key) .Returns:(Array): Returns the property values var users = [ { 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 } ]; _.pluck(users, 'user'); // → ['barney', 'fred']
  • 13. _where .Performs a deep comparison between each element in collection and the source object, returning an array of all elements that have equivalent property values. ._.where(collection, source) .Returns:(Array): Returns the new filtered array. var users = [ { 'user': 'barney', 'age': 36, 'active': false, 'pets': ['hoppy'] }, { 'user': 'fred', 'age': 40, 'active': true, 'pets': ['baby puss', 'dino'] } ]; _.pluck(_.where(users, { 'age': 36, 'active': false }), 'user'); // → ['barney']
  • 14. _.uniqueId .Generates a unique ID. If prefix is provided the ID is appended to it. ._.uniqueId([prefix]) .Returns:(string): Returns the unique ID. _.uniqueId('contact_'); // → 'contact_104' _.uniqueId(); // → '105'
  • 15. _.curry .Creates a function that accepts one or more arguments of func that when called either invokes func returning its result ._.curry(func, [arity=func.length]) .Returns:(Function): Returns the new curried function. var abc = function(a, b, c) { return [a, b, c]; }; var curried = _.curry(abc); curried(1)(2)(3); // → [1, 2, 3] curried(1, 2)(3); // → [1, 2, 3] curried(1)(_, 3)(2); // → [1, 2, 3]
  • 16. _.bind .Creates a function that invokes func with the this binding of thisArg and prepends any additional _.bind arguments to those provided to the bound function. ._.bind(func, thisArg, [partials]) .Returns:(Function): Returns the new bound function. var greet = function(greeting, punctuation) { return greeting + ' ' + this.user + punctuation; }; var object = { 'user': 'fred' }; var bound = _.bind(greet, object, 'hi'); bound('!'); // → 'hi fred!' // using placeholders var bound = _.bind(greet, object, _, '!'); bound('hi'); // → 'hi fred!'
  • 17. _.bindAll .Binds methods of an object to the object itself, overwriting the existing method. Method names may be specified as individual arguments or as arrays of method names. ._.bindAll(object, [methodNames]) .Returns:(Object): Returns object. var view = { 'label': 'docs', 'onClick': function() { console.log('clicked ' + this.label); } }; _.bindAll(view); $('#docs').on('click', view.onClick); // → logs 'clicked docs' when the element is clicked
  • 18. _.get .Gets the property value of path on object. If the resolved value is undefined the defaultValue is used in its place. ._.get(object, path, [defaultValue]) .Returns:Returns the resolved Value. var object = { 'a': [{ 'b': { 'c': 3 } }] }; _.get(object, 'a[0].b.c'); // → 3 _.get(object, ['a', '0', 'b', 'c']); // → 3 _.get(object, 'a.b.c', 'default'); // → 'default'
  • 19. _template var compiled = _.template('hello <%= user %>!'); compiled({ 'user': 'fred' }); // → 'hello fred!' var compiled = _.template('<b><%- value %></b>'); compiled({ 'value': '<script>' }); // → '<b>&lt;script&gt;</b>' var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>'); compiled({ 'users': ['fred', 'barney'] }); // → '<li>fred</li><li>barney</li>' var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>'; var compiled = _.template(text, { 'imports': { 'jq': jQuery } }); compiled({ 'users': ['fred', 'barney'] }); // → '<li>fred</li><li>barney</li>'
  • 20. Reference API Documentaion : https://lodash.com/docs DevDocs: http://devdocs.io/lodash/