开发者

jQuery plugin naming convention (for the function)

开发者 https://www.devze.com 2022-12-19 02:22 出处:网络
Which casing looks better t开发者_如何学Pythono you for a jQuery plugin: $(\"#foo\").runMyPlugin();

Which casing looks better t开发者_如何学Pythono you for a jQuery plugin:

$("#foo").runMyPlugin();

or

$("#foo").runmyplugin();

Is there a naming convention for jQuery that prefers on over the other?

Thanks in advance!


I would recommend you the first one, that convention is widely used in JavaScript, even in the core language by itself, the ECMA Specification uses it, e.g.

Array.prototype.toLocaleString
Object.prototype.hasOwnProperty
Object.prototype.propertyIsEnumerable
// etc...

All identifiers are named with camelCase, and only constructor functions are named with the first letter as capital (PascalCase).

0

精彩评论

暂无评论...
验证码 换一张
取 消