Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

175
Views
Array of Arrays in JavaScript. Replacement for querySnapshot.forEach

so I got this.

const querySnapshot = await getDocs(collectionRef);
querySnapshot.forEach((doc) => {
  console.log(doc.id, " => ", doc.data());
});

It outputs the following.

0  =>  Object
1 =>  Object
2  =>  Object

I want an array of arrays. Just like this.

[[0],
 [1],
 [2]]

Please help

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Well you can create and external array and push you values in there like so:

const array = [];

const querySnapshot = await getDocs(collectionRef);

querySnapshot.forEach((doc) => {
  array.push([doc.id])
});

console.log(array); // [[0],[1],[2]]
about 4 years ago · Juan Pablo Isaza Report

0

If you reach into docs of the snapshot, you get an array and can use all array operations, such as map:

const arr = querySnapshot.docs.map((doc) => [doc.id]);
console.log(arr);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!