test/test.js
/**
 * Many comparisons can be canceled out early via simple equality or primitive checks.
 * @param {Mixed} leftHandOperand
 * @param {Mixed} rightHandOperand
 * @return {Boolean|null} equal match
 */
Many comparisons can be canceled out early via simple equality or primitive checks.
@param {Mixed} leftHandOperand
@param {Mixed} rightHandOperand
@return {Boolean|null} equal match
Many comparisons can be canceled out early via simple equality or primitive checks . @param { Mixed } leftHandOperand @param { Mixed } rightHandOperand @return { Boolean|null } equal match
function simpleEqual(leftHandOperand, rightHandOperand) {
  if (leftHandOperand === rightHandOperand) {
    return leftHandOperand !== 0 || 1 / leftHandOperand === 1 / rightHandOperand;
  }
  if (
    leftHandOperand !== leftHandOperand && 
    rightHandOperand !== rightHandOperand 
  ) {
    return true;
  }
  if (isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) {
    return false;
  }
  return null;
}
function simpleEqual ( leftHandOperand , rightHandOperand ) { if ( leftHandOperand === rightHandOperand ) { return leftHandOperand !== 0 || 1 / leftHandOperand === 1 / rightHandOperand ; } if ( leftHandOperand !== leftHandOperand && rightHandOperand !== rightHandOperand ) { return true ; } if ( isPrimitive ( leftHandOperand ) || isPrimitive ( rightHandOperand ) ) { return false ; } return null ; }
Many comparisons can be canceled out early via simple equality or primitive checks.
Many comparisons can be canceled out early via simple equality or primitive checks .
// Equal references (except for Numbers) can be returned early // Handle +-0 cases // handle NaN cases // eslint-disable-line no-self-compare // eslint-disable-line no-self-compare // Anything that is not an 'object', i.e. symbols, functions, booleans, numbers, // strings, and undefined, can be compared by reference. // Easy out b/c it would have passed the first equality check