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[]
.
.
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