Advertisement
nikolayneykov92

Untitled

Jan 13th, 2020
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let someObject = {
  2.   a: {
  3.     b: {
  4.       e: {}
  5.     },
  6.     c: {},
  7.     d: {},
  8.   },
  9. };
  10.  
  11. const printAllKeys = (obj) => {
  12.   if (typeof obj === 'object') {
  13.     const keys = Object.keys(obj);
  14.  
  15.     keys.forEach((key) => {
  16.       console.log(key);
  17.  
  18.       printAllKeys(obj[key]);
  19.     });
  20.   }
  21. };
  22.  
  23. printAllKeys(someObject);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement