Let's get to an example. Suppose, I have a Course
object with the following properties: (course' code, course's title, credit of course etc.). When expressing this as a JS object, I can do it in the following ways:
1.
const course = {
course_code: 'CSE123',
course_title: 'An example title',
course_credit: 4
}
2.
const course = {
code: 'CSE123',
title: 'An example title',
credit: 4
}
Pro of Option 1 to me seems that it's easy to understand what object's properties are being accessed just by looking at the property name. But its quite verbose
But Option 2 is less verbose and avoids repeating the same thing.
What are the conventions regarding this? I would love some resources on this.