admin管理员组文章数量:1390670
What is the standard convention naming for property inside object?
camelCase
or
snake_case?
Here's an example:
let objPerson = {
first_name: 'first',
last_name: 'last'
};
or
let objPerson = {
firstName: 'first',
lastName: 'last'
};
Any remendation for a site to learn naming standardization of objects? I tried to google it but couldn't find an answer. Also the name of the object should be objPerson
or ObjPerson
because it is an object
What is the standard convention naming for property inside object?
camelCase
or
snake_case?
Here's an example:
let objPerson = {
first_name: 'first',
last_name: 'last'
};
or
let objPerson = {
firstName: 'first',
lastName: 'last'
};
Any remendation for a site to learn naming standardization of objects? I tried to google it but couldn't find an answer. Also the name of the object should be objPerson
or ObjPerson
because it is an object
- 1 You can choose - only real convention for name format is to start constructor and classes with a capital (and even then it's your own choice). – Jack Bashford Commented Mar 29, 2019 at 8:52
- i would go for the second option, because it is shorter to write and underscores makes code nervous. – Nina Scholz Commented Mar 29, 2019 at 8:54
- PascalCase for classes and camelCase for the rest are conventional in JS. There's no official standard. – Estus Flask Commented Mar 29, 2019 at 9:08
- There is no rule, however there is a rule that string literals should be terminated. – trincot Commented Mar 29, 2019 at 9:12
- As other have said, it's a matter of personal preference (I'm on board with @estus). Whatever you decide on, it might be a good idea to set up eslint and set a rule with your choice, so you are consistent. – Atheist Commented Mar 29, 2019 at 9:31
1 Answer
Reset to default 4It's not really a standard, but i've seen more snake case in my days. You can choose whatever you like, it's just important that you use the same type during a project.
本文标签:
版权声明:本文标题:javascript - What is the standard naming convention of properties in a object, camelCase or snake_case? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744741136a2622614.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论