Object foreach is not a function


#1

how to foreach object in ionic 3? because I get an error message like this “Object foreach is not a function”.
this my code,

let kursiss = {9C: "", 9D: "1"};
kursiss.forEach((key, value) => {
    this.list_kursi_dipesan += value=="1"?key+',':'';
    console.log(value+':-:'+key);
   
  });


#2

you don’t loop an object with for each.


#3

probably that can help: https://stackoverflow.com/questions/921789/how-to-loop-through-a-plain-javascript-object-with-the-objects-as-members


#4

You can’t loop on an object. But you can loop over object.keys().


#5

must declare properly the object

e.g

let kursiss = [{ key: 9C , value: ""},{ key: 9D, value: ""}];

for(let _obj of kursiss)
{
 console.log("value ->",_obj.key);
}