I have the following function
function hello() {
alert(\"hi!\");
}
Take this piece of code:
var elem = document.getElem
Pretty much all statements in JavaScript have a return value. Unless otherwise specified, functions in JavaScript will return undefined
when called. So, the only context in which it would make sense to call your function in this assignment statement if it were to return a function:
function hello() {
return function() {
alert("hi!");
}
}
elem.onclick = hello();