lodash#keys JavaScript Examples

The following examples show how to use lodash#keys. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: helper.js    From d2admin-permission with MIT License 6 votes vote down vote up
/**
 * 比较两个对象是否值一样 忽略顺序
 * @param {Array} array1 比较的对象
 * @param {Array} array2 比较的对象
 */
export function isIdenticalObject (object1, object2) {
  let result = true
  const keys1 = keys(object1)
  const keys2 = keys(object2)
  if (!isIdenticalArray(keys1, keys2)) {
    result = false
  } else {
    keys1.forEach(keyName => {
      if (object1[keyName] !== object2[keyName]) {
        result = false
      }
    })
  }
  return result
}