while calling a function in javascript , we generally call it by myFunction() ,(myFunction is a random function) but in the code given below btn.onclick=bgChange is given without () , how is that possible ? Should'nt it return function description instead?
var btn = document.querySelector('button');
function random(number) {
return Math.floor(Math.random()*number);
}
function bgChange() {
var rndCol = 'rgb(' + random(255) + ',' + random(255) + ',' + random(255) + ')';
document.body.style.backgroundColor = rndCol;
}
btn.onclick = bgChange;