4 ms·
There's nothing wrong with if statements. If you can't even understand the code yourself it's a sign that it needs to be rewritten. function x(result, Skip,
by z3t4 9y ago
There's nothing wrong with if statements. If you can't even understand the code yourself it's a sign that it needs to be rewritten.
function x(result, Skip, obj, traverseObject, treverseArray) {
if(! result instanceof Skip) return result;
if(typeof obj === "object") return traverseObject(Object.keys(obj));
if(Array.isArray(obj)) return traverseArray(obj);
return new Skip("Not found.");
}
- benoits 9y agoAgreed. I don't see what is so evil about early returns, they seem very clear to follow to me. Especially with proper IDE syntax highlighting.