I am playing around with JavaScript and AngularJS since a few days and I am not sure about the following:
I am working on a sample project in which a user is able to create a new car with just a few properties stored in an JS object like this:
var car = {
color: 'black',
seating: 'leather',
fuelconsumption: 'moderate'
}
The user can create a new car by clicking on an add-button. Angular then creates a new instance of a car and the user can specify the wishes for new car.
However, should I create an empty object like
var car = {}
and add the needed keys using the bound text inputs or should I do something different?
Since the properties of a new car are known a-priori I could also create an object with the needed keys and null
as their values like this:
var car = {
color: null,
seating: null,
fuelconsumption: null
}
Which way would be more preferable due to e.g. best-practise?