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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Encapsulation in JavaScript

1 点作者 dabent超过 15 年前

1 comment

seasoup超过 15 年前
I've been developing javascript for web applications and large consumer web sites for 10 years. Functional to OO to JSON notation. The ability to create a private function is a neat theoretical exercise, but the amount of code or change in coding patterns necessary to implement private functions is complete overkill.<p>Unless you are developing a huge javascript driven application, it does not actually matter if a method is private or public. Just don't call it. Much simpler/cleaner code, easier to read, easier to maintain. I'm a big proponent of making code simple instead of complex and private functions in javascript just add complexity.<p>Now, although I am skeptical, I would love to hear other commentors experience where they found private functions in javascript to be invaluable. What have you coded where making a method private added value to your code making it worth the increased complexity?