Defining properties and naming conventions in JavaScript

丶灬走出姿态 提交于 2019-12-03 01:52:21

I would suggest not following Crock's teaching word for word.

He does have some good advice, but it's worth taking it with a grain of salt.

For example, the underscore aspect is commonly used in various JS libraries which follow a more classical OOP style of programming. It is true it does not make a function or value truely private, but it tells any users it should be treated as such - that it's not a part of the public interface - in other words, the method could disappear in the next version of the library.

The convention for naming constant-like values is also ALL_CAPS_WITH_UNDERSCORE even though JS didn't actually have constants.

In the end, many JS devs are not purely JS-only and work with other languages too. Conventions like the above should be rather obvious for people like that, and what matters in the end is what's most practical for your project.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!