Objects don't just come with static property values—some of these values are callable functions. Functions assigned as an object's property are often referred to as methods, since they're generally interacting with the encapsulated state of the object to which they belong. Other times, objects are just a convenient vehicle for assigning and passing functions around the code. At the end of the day, they're just functions assigned to property values and Lo-Dash has some functions that assist with finding and calling them.
We can use the result()
function when we're unsure whether a given property name is a function or another type. This can simplify our code greatly because we don't need to write code that checks whether the property should be accessed like a regular static property value or if the property needs to be invoked. The usage of the result()
function is shown in the following code:
var object1 = { name: 'Brian' }, object2 = { ...