For performance you're going to want to get rid of the left/right undefined checks above and just go with:

```javascript
return left === right ||
         typeof left !== 'undefined' &&
         typeof right !== 'undefined' &&
         // other checks
```

The first check here, `left === right` is a reference equality check that will be very fast.