Tag Archives: javascript

Stream video with getUserMedia()

Request the user to start their webcam stream var video= document.querySelector(“#videoElement”); if(navigator.mediaDevices.getUserMedia){ navigator.mediaDevices.getUserMedia({ video: true }) .then(function (stream) { video.srcObject = stream; }) .catch(function (error) { console.log(“Error streaming”); }); } Using the getUserMedia() API which allows you to access a user’s camera and mic without any plugins Streams have inputs (video) and outputs (video) The… Read More »

forEach( ), sort( ) and filter( ) for newbies

forEach() ES6 has introduced the forEach() method which allows you to loop through an array. Arrays as you may already know are of the type ‘object’. In contrast to the string,number,boolean, undefined and symbol types which are primitive data types. For example if we console.log the typeof operator to find the typeof array, objectwill be… Read More »

JavaScript filter()

Part of my “Functional JavaScript” programming notes Syntax: let newArray = Oldarray.filter(callback(element, index, array)); Explanation: The filter method returns a new array from the filtered items from the oldArray Items are filtered according to some condition To do so a callback function is used The callback function takes 3 arguments: element: The current element index:… Read More »