Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: Jenya Mia
Added: Apr 3, 2019 4:07 PM
Views: 27
Tags: javascript
  1. // hasOwnProperty approach
  2.  for (key in obj) {
  3.   if (obj.hasOwnProperty(key)) {
  4.     value = obj[key];
  5.   }
  6. }
  7.  
  8. // Object.keys approach
  9. keys = Object.keys(obj);
  10. for (i = 0, l = keys.length; i < l; i++) {
  11.   value = obj[keys[i]];
  12. }