TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

LBYL or EAFP for JavaScript?

1 点作者 sonicrocketman超过 9 年前
Python is EAFP, and Swift is LBYL. What is the best choice for Javascript?<p>For those who don&#x27;t know:<p>EAFP: Easier to Ask Forgiveness than Permission (try&#x2F;catch) LBYL: Look Before You Leap (if condition: do thing)

1 comment

smt88超过 9 年前
Creating 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).<p>Unfortunately, there isn&#x27;t much of a standard in how libraries do things, so you won&#x27;t ever have a cohesive standard in your own code.<p>For that reason, I suggest using whatever style creates more readable&#x2F;maintainable code for you and your team. I suspect that it&#x27;s LYBL, since that helps you avoid goto-based functionality, but it&#x27;s a personal choice.