I got quite confused with Function.prototype.bind()
method.
function playsound(raw) {
}
function onfilechange(then, evt) {
var reader = new FileReader();
reader.onload = function (e) {
console.log(e);
then(e.target.result);
};
reader.onerror = function (e) {
console.error(e);
};
reader.readAsArrayBuffer(evt.target.files[0]);
}
document.getElementById('file')
.addEventListener('change', onfilechange.bind(null, playsound), false);
Can anyone explain to me what this code fragment does? The this
is null and second argument is the playsound
function. I am not quite understanding the usage behind the below line.
onfilechange.bind(null, playsound)