Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 558
Mark Rajcok Avatar asked Mar 13 '13 23:03

Mark Rajcok


People also ask

Is JavaScript required to learn AngularJS?

Using Angular effectively requires that you understand the fundamentals of JavaScript. What's more, the value you derive from Angular will be proportional to how adept you are at JavaScript. I don't recommend learning Angular without at least a basic understanding of JavaScript.


2 Answers

  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!

like image 112
Mark Rajcok Avatar answered Nov 11 '22 20:11

Mark Rajcok


In my view you should get clarity on the following topics

1) call by value vs call by reference in javascript

Reason: because in angularJS we deal with a lot of objects. You will be clear about their behaviour once you understand this

2) Scope chain and IIFE(Immediately invocable function expression)

Reason: When you work on an application using angularJS IIFEs play a major role in manipulating your scope.

3) Closures

Reason: One of the most important javascript concept. If you see source code of a lot of famous libraries and frameworks built on javascript, they have used closures a lot. Closures will also help you understand how factories work in depth.

4) Dependency Injection

Reason: A javascript concept on which Angular JS is based

5) You can also go through some good style guides for AngularJS. For instance you can refer to this one: https://github.com/johnpapa/angular-styleguide

like image 22
Rahul Arora Avatar answered Nov 11 '22 21:11

Rahul Arora