Mark Rajcok Mark Rajcok - 6 months ago 8
AngularJS Question

What five JavaScript concepts do I need to understand to be a good AngularJS developer?

Suppose I'm used to coding on the server side (with server-side languages), and now I'm learning AngularJS. That means I first need a good understanding of JavaScript.

If I don't have to time to fully learn JavaScript right now, what five JavaScript concepts would you recommend I learn first/well in order to be an effective AngularJS developer?

Answer
  1. the type system: there are two fundamentally different kinds of values: primitives and objects. Number, string, boolean, null, undefined are all primitives.
    Array ( [1,2,3] ), object ( { prop1: value1, prop2: value2 } ), and function are all objects.
  2. prototypal inheritance – this is especially important when you attempt to databind in AngularJS to a primitive
  3. array['syntax'] === array.syntax; array['$id'] === array.$id; array[someExpression] has no eqivalent "." notation
  4. variable scope and assignment
    • a variable defined anywhere inside a function is visible everywhere inside that function
    • when a variable is assigned an object, it is assigned a reference (not a copy). This becomes important in AngularJS when, e.g., you fetch JSON data from a server and you assign the results to a variable. This resets the reference. Other variables (say in your controller) that point to the old reference continue to point to the old reference. (example)
  5. closures – these are very useful when defining AngularJS services (example) and when defining methods on a controller using this (example)

Also note that JavaScript is single-threaded!