Would it be possible to nest the object e.g. Object = {vehicle:car, insuranceStatus:insurance} where car = {make: "Honda", colour:"Blue"} etc. Would that be a good or a rather bad practice?
@Greenemath3 жыл бұрын
We will get to nested objects pretty soon. To answer your question, the value for a property can be a variable that is also an object. const car = { make: "Honda", color: "Blue" } const obj = { vehicle: car, insuranceStatus: true } console.log(obj.vehicle); {make: "Honda", color: "Blue"} Is it a good practice? The answer is always it depends on the situation. If you are new, I would say just make things work, later on you can worry about speed and optimization.
@laponiec3 жыл бұрын
@@Greenemath I see, iterating through these objects could be quiet problematic.
@Greenemath3 жыл бұрын
@@laponiec It won't be too bad. We just aren't there yet. We have for in loops and Maps, we just haven't gotten there just yet.