Unable to get vanilla JavaScript syntax or maybe I have brainfreeze.
const xhttp = new XMLHttpRequest();
xhttp.onload = function() {
console.log('hello');
}
xhttp.open("GET", "my data.txt");
xhttp.send();
The onload function is defined and called immediately, why don't we need to call it seperately after defining like other normal functions?