[英]Naming conventions in JavaScript for functions inside objects?
I would like to be sure I am using the most common naming convention. 我想确定我使用的是最常见的命名约定。 In the example below would it be more common for
deleteEntity
to be deleteEntity
or DeleteEntity
? 在下面的示例中,
deleteEntity
是deleteEntity
还是DeleteEntity
更常见吗?
var factory = {
deleteEntity: function (entityType, entityId) {
var deferred = $q.defer();
EntityResource.deleteEntity({ entityType: entityType, entityId: entityId },
function (resp) {
deferred.resolve(resp);
}
);
return deferred.promise;
},
It would be more common to be lowercase. 小写会更常见。 It would still work, but generally capital Functions are reserved for constructors (ie used with the
new
keyword). 它仍然可以工作,但是通常大写的函数保留给构造函数使用(即与
new
关键字一起使用)。
There are no set naming conventions that I know of as such. 据我所知,没有设置命名约定。 But as a Java developer, I will be happy to see variables and methods following lower Camel Casing like
deleteEntity
. 但是作为Java开发人员,我很高兴看到下面的Camel Casing之后的变量和方法,例如
deleteEntity
。 But Dot net developers may be comfortable with Upper camel casing like "DeleteEntity". 但是,Dot网络开发人员可能会对“ DeleteEntity”之类的上层骆驼套感到满意。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.