KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to gain a deeper understanding of how Javascript works and the following code is bugging me: function notInVar(a, b) { return a + b } var inVar = function doesThisWork(a, b) { return a + b } document.writeln('2 + 2 = ' + notInVar(2, 2)); document.writeln('3 + 3 = ' + inVar(3, 3)); document.writeln('4 + 4 = ' + doesThisWork(4, 4)); In Chrome, the first two document.writelns execute as expected, then I get "Uncaught ReferenceError: doesThisWork is not defined" in Chrome. Why can't I call the second function by the name doesThisWork ? For that matter, where is the first function-object notInVar stored?
Tags (comma-separated)
Save Edits
Cancel