How to correct this kind of problem?

How to correct the problem of

The body of a for-in should be wrapped in an if statement to filter unwanted properties from the prototype eslint reporting error? The
code says

 for ( x in myemrList) {
          arr.push(myemrList[x].hospital_id);
        }
Apr.15,2021

 for ( x of myemrList) {
    
       arr.push(myemrList[x].hospital_id);
 
          
}

if myemrList is an object

for ( x in myemrList) {
      if(myemrList.hasOwnProperty(x)) {
          arr.push(myemrList[x].hospital_id);
      }
}

if it's an array, use for.of

.
Menu