Alan2
Alan2

Reputation: 24572

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?

var factory = {
    deleteEntity: function (entityType, entityId) {
        var deferred = $q.defer();
        EntityResource.deleteEntity({ entityType: entityType, entityId: entityId },
           function (resp) {
               deferred.resolve(resp);
           }
        );
        return deferred.promise;
    },

Upvotes: 0

Views: 288

Answers (2)

midhunhk
midhunhk

Reputation: 5554

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. But Dot net developers may be comfortable with Upper camel casing like "DeleteEntity".

Upvotes: 0

CWSpear
CWSpear

Reputation: 3270

It would be more common to be lowercase. It would still work, but generally capital Functions are reserved for constructors (i.e. used with the new keyword).

Upvotes: 4

Related Questions