Capitalization convention for JavaScript objects

我的未来我决定 提交于 2019-11-30 08:21:34
Pavel Hodek

You can follow this Google JavaScript Style Guide

In general, use functionNamesLikeThis, variableNamesLikeThis, ClassNamesLikeThis, EnumNamesLikeThis, methodNamesLikeThis, and SYMBOLIC_CONSTANTS_LIKE_THIS.

The convention is that there is no convention. Do what you want, just be consistent. I suggest follow Java style and ignore whatever convention the library (dojo, Ext, YUI, $, etc) you happen to be using is following.

I agree with the capitalization of functions that define "classes" (air-quotes used) that in turn will be instanciated later using the new operator.

But that's it. Global objects are just global. Name them what you want.

All I would make sure is that they are unique and descriptive enough that they won't be overwritten accidentally by another developer at a later date.

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