function doSomething(fn) {
fn("Hello");
}
doSomething(alert);
The result of the run is to pop up Hello
what the fn ("Hello")
means here, and doSomething (alert)
, which passes the alter function as an argument, but I don"t understand how it works. Also, if you use alert (doSomething)
, you will output
function doSomething(fn) {
fn("Hello");
}
Please explain it in more detail, thank you