Javascript: coding standards, Pascal corpus or Camel corpus?

I am making a function call and passing on an array of objects, but I am not sure whether to use CamingCasing or PascalCasing. Here is my method



If you notice that I was going through DefaulText, but should it be defaultText? and also the elements, should they be? and inside Items, and I also pass the Id and Title.

Can anyone confirm the correct way to do this?

I know the methods are camelCasing, but are they passed in objects like above?

Thank you in advance


source to share

2 answers

The most popular JavaScript convention is to use PascalCasing, since you call it on constructors (classes) like String, Number, Date and camel casing for variable names and object keys. This code convention is used for all built-in JavaScript functionality in modern browsers, so I would recommend using it for your own code as well.



There is no right way.

The JavaScript API uses camelCase for functions and PascalCase for objects.

Just pick one and be consistent . JavaScript identifiers are case sensitive.



All Articles