Simple way to loop through a JavaScript object array? I have an object array and i am using gulp 4.
libs:
    {
        a: {
          js: [
            {
              src: 'path/from/a1.js',
              dest: 'path/to/a1.js',,
            },
            {
              src: 'path/from/a2.js',
              dest: 'path/to/a2.js',,
            },
          ],
          css: [
            {
              src: 'path/from/a1.css',
              dest: 'path/to/b1.css',,
            },
          ],
        },
        b: {
          js: [
            {
              src: 'path/from/b.js',
              dest: 'path/to/b.js',,
            },
          ],
        },
      }

I need to know all the src and dest values ​​so that I can move files from src to dest.
const moveLibs = (done) =&gt; {
  Object.entries(libs).forEach(([key, value]) =&gt; {
    const types = value;

    Object.entries(types).forEach(([key, value]) =&gt; {
      const srcAndDest = value;

      Object.entries(srcAndDest).forEach(([key, value]) =&gt; {
        return gulp
          .src(value.src)
          .pipe(gulp.dest(value.dest));
      });
    });
  });

  done();
};

This method is successful, but I feel that it is not simple enough, please tell me a simpler method, thank you.
A short review;

I prefer to use the function keyword
You are using libs like a global, I would pass it in the function
If you don't need both key and value, then you can just use Object.values
Building on that, you might as well use a properly named function parameter and cut the lines in two



function moveLibs(libs, done){
  Object.values(libs).forEach(types =&gt; {
    Object.values(types).forEach(srcAndDest  =&gt; {
      Object.values(srcAndDest).forEach(value =&gt; {
        console.log(`Piped ${value.src} to ${value.dest}`);
      });
    });
  });

  done();
};

libs=
    {
        a: {
          js: [
            {
              src: 'path/from/a1.js',
              dest: 'path/to/a1.js',
            },
            {
              src: 'path/from/a2.js',
              dest: 'path/to/a2.js',
            },
          ],
          css: [
            {
              src: 'path/from/a1.css',
              dest: 'path/to/b1.css',
            },
          ],
        },
        b: {
          js: [
            {
              src: 'path/from/b.js',
              dest: 'path/to/b.js',
            },
          ],
        },
      };


moveLibs(libs, ()=&gt;console.log("Hello World!"));