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

234
Views
Getting empty array in javascript using array.push() method

I am trying to push data into array in this code

let eyesData = [];

const pushFaceData = (
    { rightEyeOpenProbability },
    i
  ) => {
    //Value is getting printed  in console but not getting pushed
    //console.log(rightEyeOpenProbability);
    eyesData.push(rightEyeOpenProbability);
   
  };

const renderFaces = () => {
    faces.map(pushFaceData);
  };

console.log(eyesData);

faces is stream of data that updates itself in every 100ms so eyesData array should also be getting populated on each 100ms but in console, eyesData is always getting printed with empty value.

Array[]
Array[]
.
.
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If rightEyeOpenProbability is printing to the console, then there is no reason your code should be failing...

You are probably changing eyesData somewhere. For example, if you made a typo when checking its length, you could be erasing it:

if( eyesData.length = 0 ) { ... } //this line would erase eyesData[]'s contents
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!