Http://stackoverflow.com/questions/2628672/what-should-every-javascript-programmer-know
Not jQuery. Not YUI. Not (etc etc.)
Frameworks May is useful, but they is often hiding the sometimes-ugly details of how JavaScript and the DOM actually work From you. If your aim is the able to the say "I know JavaScript", then investing a lot of time on a framework is opposed to that.
Here is some JavaScript language features that's should know to grok what it's doing and not get caught out but which Aren ' t immediately obvious to many people:
object.prop
object[‘prop‘]
that and is the same thing (so can-you-stop using eval
, thanks); That object properties is always St Rings (even for arrays); What ... is the for (and what for
in
it isn ' t).
property-sniffing; What are (and why undefined
it smells), why the Seemingly-little-known in
operator are beneficial and different from typeof
/ checks; hasOwnProperty
; The purpose of delete
.
The Number
datatype is really a float; the language-independent difficulties of using floats; avoiding the parseInt
Oct Al Trap.
Nested function Scoping; The necessity of using in the var
scope you want to avoid accidental globals; How scopes can is used for closures; the C Losure loop problem.
How global variables and window
properties collide, how global variables and document elements shouldn ' t collide IE; The necessity of using in var
global scopes too to avoid this.
How the function
statement acts to ' hoist ' a definition before code preceding it; the difference between function statements and function expressions; Why named function expressions should isn't be used.
How constructor functions, the property and the prototype
new
operator really work; methodsof exploiting this to create the Normal class/subclass/instance system you actually wanted; When you might want to use closure-based objects instead of prototyping. (Most JS tutorial material are absolutely terrible on the; it took me years to get it straight in my head.)
How this
are determined at call-time, not bound; What consequently method-passing doesn ' t work like you expect from the other L Anguages; How closures or May is Function#bind
used to get around.
Other ECMAScript fifth Edition features like indexOf
, and the forEach
functional-programmingmethods on Array
; Der browsers to ensure your can use them; Using them with the inline anonymous function expressions to get compact, readable code.
The flow of control between the browser and user code; synchronous and asynchronous execution; Events that fires inside the flow of control (eg. focus) vs. events and timeouts that occur when control returns; How calling a supposedly-synchronous builtin as alert
can end up causing potentially-disastrous re-entrancy.
How Cross-window scripting affects instanceof
, how Cross-window scripting affects the control flow across different documents; How would postMessage
hopefully fix this.
See this answer regarding the last of the items.
Most of all, you should being viewing JavaScript critically, acknowledging that it's for historical reasons an imperfect LAN Guage (even more than most languages), and avoiding its worst troublespots. Crockford's work on this front is definitely worth reading (although I don ' t 100% agree with him on which the "Good Parts" are).
What should every JavaScript programmer know?