Complex expressions and repeated code should be extracted into well-named variables to improve readability and maintainability. This applies to:

Example - Instead of:

if ([options.path, responseDetails.headers.location].every(item => item === '/foo')) {
  // ...
}

Better approach:

const isPathMatching = options.path === '/foo';
const isLocationMatching = responseDetails.headers.location === '/foo';
if (isPathMatching && isLocationMatching) {
  // ...
}

This practice: