I have an javascript object returned from c# class library. Object is simple name - value pairs list.
I'm using
for (var myList in myListItems) {
console.log(myList);
console.log(myListItems[myList]);
}
to retrieve all items in list, but next to my items, i'm getting a bunch of .toString methods and several others, probably inherited from something.
Is there a way to remove all this methods, and get only data i need?
hasOwnPropertywould probably help.for...inwill iterate over all enumerable properties of the object and its prototype(s). If you can clearly identify the characteristics of the properties you don't want, then there might be a way to do that. But your current description is incomplete / vague.hasOwnPropertyworks in this case.