Object Functions Flashcards
_.keys(object)
Retrieve all the names of the object’s own enumerable properties.
_.allKeys(object)
Retrieve all the names of object’s own and inherited properties.
_.values(object)
Return all of the values of the object’s own properties.
_.mapObject(object, iteratee, [context])
Like map, but for objects. Transform the value of each property in turn. Iter: function(val, key)
_.pairs(object)
Convert an object into a list of [key, value] pairs.
_.invert(object)
Returns a copy of the object where the keys have become the values and the values the keys. For this to work, all of your object’s values should be unique and string serializable.
_.create(prototype, props)
Creates a new object with the given prototype, optionally attaching props as own properties. Basically, Object.create, but without all of the property descriptor jazz.
_.functions(object)
Returns a sorted list of the names of every method in an object — that is to say, the name of every function property of the object.
_.findKey(object, predicate, [context])
Similar to _.findIndex but for keys in objects. Returns the key where the predicate truth test passes or undefined.
_.extend(destination, *sources)
Copy all of the properties in the source objects over to the destination object, and return the destination object. It’s in-order, so the last source will override properties of the same name in previous arguments.
_.extendOwn(destination, *sources)
Like extend, but only copies own properties over to the destination object.
_.pick(object, *keys)
Return a copy of the object, filtered to only have values for the whitelisted keys (or array of valid keys). Alternatively accepts a predicate indicating which keys to pick.
_.omit(object, *keys)
Return a copy of the object, filtered to omit the blacklisted keys (or array of keys). Alternatively accepts a predicate indicating which keys to omit.
_.defaults(object, *defaults)
Fill in undefined properties in object with the first value present in the following list of defaults objects.
_.clone(object)
Create a shallow-copied clone of the provided plain object. Any nested objects or arrays will be copied by reference, not duplicated.
_.tap(object, interceptor)
Invokes interceptor with the object, and then returns object. The primary purpose of this method is to “tap into” a method chain, in order to perform operations on intermediate results within the chain.
_.has(object, key)
Does the object contain the given key? Identical to object.hasOwnProperty(key), but uses a safe reference to the hasOwnProperty function, in case it’s been overridden accidentally.
_.property(key)
Returns a function that will itself return the key property of any passed-in object.
_.propertyOf(object)
Inverse of _.property. Takes an object and returns a function which will return the value of a provided property.
_.matcher(attrs)
Returns a predicate function that will tell you if a passed in object contains all of the key/value properties present in attrs.
_.isEqual(object, other)
Performs an optimized deep comparison between the two objects, to determine if they should be considered equal.
_.isMatch(object, properties)
Tells you if the keys and values in properties are contained in object.
_.isEmpty(object)
Returns true if an enumerable object contains no values (no enumerable own-properties). For strings and array-like objects _.isEmpty checks if the length property is 0.
_.isElement(object)
Returns true if object is a DOM element.
_.isArray(object)
Returns true if object is an Array.
_.isObject(value)
Returns true if value is an Object. Note that JavaScript arrays and functions are objects, while (normal) strings and numbers are not.
_.isArguments(object)
Returns true if object is an Arguments object.
_.isFunction(object)
Returns true if object is a Function.
_.isString(object)
Returns true if object is a String.
_.isNumber(object)
Returns true if object is a Number (including NaN).