Re: Javascript Question: What is the difference between calling funcName and funcName
At this point, we're getting away from what a knowledge of procedural programming style can help you with. I know that JavaScript
looks like a C-style/Java-esque language on the surface (syntactic elements like curly braces and semicolons can lead you down the garden path), and as Ed Post remarked in '82, a "determined Real Programmer can write FORTRAN in
any language,"* but there are some things that just can't be understood about JS unless you realise that looks can be incredibly deceiving.
JS may have inherited its looks from the Algol/C family of languages, but it got its prototypal inheritance from Self and the best parts of its behaviour from Scheme (a dialect of Lisp).† In order to use the language effectively, you really need to "get" higher-order functions (and what functional programming is in general) and closures. If you want to pass "sticky" parms, you'd use a closure; if you want to be able to pass parms at a deferred time, you'd use a higher-order function (a function that creates the function that you actually need on demand); and there are times when you don't really need either since the function can determine what it needs on its own.
Probably the best current description of the language at that level is in Douglas Crockford's book
JavaScript: The Good Parts. (The PDF is about $24, it's DRM-free, and you own it forever and once you've bought it, you can download it for as long as you and O'Reilly media both shall live.) And even that might be a bit of a stretch if you're walking into it cold, so I usually suggest that people at least watch the
SICP (Structure and Interpretation of Computer Programs) lecture series by Hal Abelson and Gerry Sussman. That series was recorded at a company-sponsored fast-track version of MIT's 6.001 computer science course for Hewlett Packard employees, it's very accessible to just about anybody who can remember tiny flashes of, say, a tenth-grade math education, and it's free (modulo bandwidth charges from your ISP, since the entire series—20 lectures averaging about an hour each—is about 8.5 GB in size). It's really hard to express how much of an effect that one course can have on the way you think about programming in any language and computing in general, even if all you do is watch the lectures.‡
__________________________________________
* Back in the day, when Netscape Navigator still roamed the planet, it's safe to say that almost all of us were using JavaScript as if it were Visual Basic.
† It's a bit of a mess, but when you consider that Brendan Eich knocked it together in ten days and had to add all sorts of "just get it working right now" hooks for his fellow Netscapers to use in a rush to release, you can almost forgive the inelegance.
‡ Getting the book and doing the exercises, or actually taking the full MIT OpenCourseware version of the course can lead to immense dissatisfaction with the state of computing in the wild, a strong addiction to Lisp, an irrational belief that the whole universe should be tail-call optimised and general curmudgeonliness. You have been warned.