Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
166
rated 0 times [  170] [ 4]  / answers: 1 / hits: 16448  / 8 Years ago, thu, december 1, 2016, 12:00:00

so i have object that have many properties, i need to get all values and property names from that object, i'm not sure what is best and easiest way to do it. I already tried few methods but didn't had any luck with it



angular.forEach(array, function(value, key){
console.log(value);
});

More From » angularjs

 Answers
40

forEach works with arrays, for object properties you need:



for (var property in object) {
if (object.hasOwnProperty(property)) {
console.log(property, ' ', object[property]);
}
}

[#59847] Wednesday, November 30, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
analiseb

Total Points: 252
Total Questions: 96
Total Answers: 106

Location: Singapore
Member since Sat, Jul 25, 2020
4 Years ago
analiseb questions
;