3 ms·
LBYL or EAFP for JavaScript?
Python is EAFP, and Swift is LBYL. What is the best choice for Javascript?
For those who don't know:
EAFP: Easier to Ask Forgiveness than Permission (try/catch)
LBYL: Look Before You Leap (if condition: do thing)
- smt88 11y agoCreating something that works in JavaScript requires hooking lots of libraries together. A recent bare-bones API project I was working on had 70 libraries (only 10 of which were surface-level, the rest were dependencies). Unfortunately, there isn't much of a standard in how libraries do things, so you won't ever have a cohesive standard in your own code. For that reason, I suggest using whatever style creates more readable/maintainable code for you and your team. I suspect that it's LYBL, since that helps you avoid goto-based functionality, but it's a personal choice.