visit
const complexFunction = (a, b) => a + b;
const complexFunction = (a, b) => {
console.log("[DEBUG]", a, b);
return a + b;
}
const complexFunction = (a, b) => console.log("[DEBUG]", a, b) || a + b;
"Logical operators are typically used with Boolean (logical) values. When they are, they return a Boolean value. However, the && and || operators actually return the value of one of the specified operands, so if these operators are used with non-Boolean values, they will return a non-Boolean value"- Because console.log resolves tofalsy, the function will return the second part of it, which in our case is the a + b . Pretty neat, right? Final wordsDiscovering this small trick was game-changer when it comes to debugging arrow functions more efficiently. What do you think of this technique? Did you know about this before? Let's continue the discussion in the comments section.Thanks for reading, and subscribe to do not miss out on any of my future posts! 🙏
Robert is a full-stack web developer, currently working at . He loves to inspire people, explore new places, read great books, take inspiring pictures and learn new stuff all the time.
Follow him on , , or .