Mixin: Utils/UnderscoreMixins


Mixin intended to be used with _.mixin.

const Mixins = require('utils/underscore-mixins');


<static> changed(obj1, obj2)

Performs a deep-diff comparison between two objects and returns a hash mapping all keys from obj1 and obj2 to whether or not they were changed. (A key is mapped to true if there are differences, false otherwise).

It does not matter which order you pass the parameters in; the returned object will remain the same.


var newModelAttributes = {
    a: 1,
    b: {create: true, edit: false},
    c: 'test',
    d: {a: 'b', c: {d: true}}

var oldModelAttributes = {
    a: 1,
    b: {create: true},
    c: undefined,
    e: [1, 2]

_.changed(newModelAttributes, oldModelAttributes);
// {a: false, b: true, c: true, d: true, e: true}
Name Type Description
obj1 Object

The first of two objects to diff between.

obj2 Object

The second of two objects to diff between.


The hash of differences between obj1 and obj2. Returns undefined if obj1 and obj2 are empty.

Object | undefined

<static> isEmptyValue(value)

Checks to see if a value is empty.

Returns true if:

  • value is undefined or null
  • value is an empty string
  • value is an empty object
  • value is an empty array

All other values return false.

Name Type Description
value boolean | number | string | Object | Array

The value to check.


true if given an empty value; false otherwise.