mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 07:47:49 +00:00
Merge pull request #512 from braddunbar/getvalue
Add utility function `result`.
This commit is contained in:
@@ -873,6 +873,13 @@
|
||||
return (''+string).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/');
|
||||
};
|
||||
|
||||
// Get a value from an object as a property or as a function.
|
||||
_.result = function(object, property) {
|
||||
if (object == null) return null;
|
||||
var value = object[property];
|
||||
return _.isFunction(value) ? value() : value;
|
||||
};
|
||||
|
||||
// Add your own custom functions to the Underscore object, ensuring that
|
||||
// they're correctly added to the OOP wrapper as well.
|
||||
_.mixin = function(obj) {
|
||||
|
||||
Reference in New Issue
Block a user