Complex expressions and repeated code should be extracted into well-named variables to improve readability and maintainability. This applies to repeated string/value combinations, complex conditional logic, array transformations, and URL or path constructions.
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:
Enter the URL of a public GitHub repository