I have a model that looks as follows
this.Model
Model {class: undefined items: Array(0) tag: undefined launch: undefined length: undefined name: undefined Id: "de4d704a-b754-4546-b3ab-f0c131eba84a" time: "15:36" tonnage: undefined}
the only objects in the Model that will always have a value is Id and Time.
i have an if statement that goes through each off my objects to check if its null as follows:
if ( this.Model.class == null && this.Model.name == null && this.Model.tag== null && this.Model.launch == null && this.Model.length == null && this.Model.tonnage == null && this.Model.items.length == 0)
{
//does something in here
}
so i want to check if all the objects are null except time and ID, is there a better way of doing this than me using the above method in an if statement?
question from:
https://stackoverflow.com/questions/65902494/a-better-way-to-loop-through-an-array-of-items 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…