How to select proper backfacing camera in Javascript? How to select proper backfacing camera in Javascript? google-chrome google-chrome

How to select proper backfacing camera in Javascript?


I placed all the cameras by id into array like that

      navigator.mediaDevices.enumerateDevices()        .then(function(devices) {                for(;devices[i];){        if(devices[i].kind == "videoinput"){            that.aCameras.push(   [devices[i].deviceId , devices[i].label]   )            j++;                        }        i++;        }    });