I like to use early return statements in functions, if a feature is unsupported. This leads to incorrect warnings:
function version1() {
if (window.fetch === undefined) {
return;
}
// triggers a warning
window.fetch();
}
function version2() {
if (window.fetch !== undefined) {
// triggers no warning
window.fetch();
}
}
I prefer version1 because the remaining code within the function does not need to be indented and thus is easier to read/understand.
I like to use early return statements in functions, if a feature is unsupported. This leads to incorrect warnings:
I prefer
version1because the remaining code within the function does not need to be indented and thus is easier to read/understand.