I need to verify if the taskDetails
object contains only the lastTask
value and no other values.
To achieve this, I am currently using the approach with index [0]
as shown below:
Object.keys(this.clubdetails.taskDetails)[0]==["lastTask"]
However, I have a concern that adding another object like "currentTask" at index 1, the index of lastTask would still be ["0"]. This means that my current check for lastTask at index[0] would return true even though there are other values in taskDetails besides lastTask.
I believe there should be a more effective method to confirm if an object contains only a specific value and nothing else. Any advice on how to achieve this?https://i.sstatic.net/m092X.png