The major difference here is speech marks " "
When using the function
alert() if between the brackets your content is surrounded by speech marks, then it will alert that exact content.
alert("function") has an actual output of the word function!
leave out the speech marks and you are asking the alert not to print the word function but the var or functions content.
alert(function) no speech marks here, prints the content of the function.
hope that helps