Interview Questions Flashcards

1
Q

What is an expression in Angular?

A

Expressions are used to bind data to the view (double curly brackets)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the difference between “==” and “===” ?

A

-double equals compares two types
-triple equals compares types and values
ex, “2” == 2; //true
“2” === 2; //false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the differences between null and undefined?

A

null is an object with no value

undefined is a type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are some of the core directives in Angular?

A

ng-app
ng-model
ng-bind

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How would you improve page runtime performance as your application scales?

A
  • to achieve 60 frames per second to keep up with your refresh rate you have about 16 milli seconds for your code to execute jank-free. I would keep an eye on concurrent watches and try to keep the $watch count preferably under 2,000 because Angular is known to drastically slow down in performance time whenever your application does dirty checking and you have more than 2 - 2,500 digest cycles happening.
  • use one-time binding w/ double colon syntax
  • Debouncing ng-model updates in your ngModelOptions
  • Try and reduce ng-repeat
  • Avoid filters if possible because they run twice per digest cycle. Use $filterProvider instead because it will run filters in your javascript code before parsing it into the DOM
  • Use ng-if instead of ng-show or ng-hide. ng-if scopes are destroyed and a new scope is created whenever the conditional is met, whereas, ng-show and ng-hide simply masks the elements with css and takes more processing power
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you share data between controllers?

A
  • Services are the cleanest, fastest, and easiest way
  • events - event listeners
  • $rootScope - but you want to avoid using at all cost unless you absolutely have to.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a digest cycle in Angular?

A

a digest cycle compares old and new scoped model values

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

When does a digest cycle happen?

A

it happens whenever a new event is set off

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the difference between one-way binding and two-way binding?

A
  • one way binding implies that the scope variable in the html will be set to the first value it’s model is bound or assigned to
  • two-way binding the scoped variable changes it’s value everytime its model is assigned a new value
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How does $scope.$apply() work?

A

it looks at all the declared models and forces or applies the change to any model that have been altered. but its a bad practice it forces angular to run on all entire models and variable but sometimes necessary when dealing with third party plugins and when you’re dealing with timing issues.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Explain data binding in Angular.

A

Data synchronization between the model and view components. The view is a projection of the model at all times. When the model changes, the view reflects the change, and vice versa.”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are directives?

A

They are essentially functions that execute when the Angular compiler finds them in the DOM. Some of the most commonly used directives are ng-app,ng-controller and ng-repeat.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are controllers in Angular?

A

Controllers are Javascript functions which provide data and logic to the view. As the name suggests, they control how data flows from the server to view.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the difference between link and compile in Angular?

A
  • The compile function is used for template DOM manipulation and to collect all directives.
  • Link function is used for registering DOM listeners as well as instance DOM manipulation and is executed once the template has been cloned.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Explain what is Injector in Angular.

A

An injector is a service locator, used to retrieve object instance as defined by provider, instantiate types, invoke methods, and load modules.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is scope in Angular?

A

Scopes are objects that refer to the model. They act as glue between controller and view.

17
Q

What are services in Angular?

A

Services are singleton objects which are instantiated once within an application. ex, $http service

18
Q

Explain ng-bind directive.

A

Typically you don’t use ng-bind and use the double curly braces but in instances where the template/view is flashes in its raw html state then ng-bind or ng-cloak can solve that issue.

19
Q

Explain what is string interpolation in Angular.js ?

A

The compiler matches text and attributes using interpolate service to see if they contains embedded expressions. As part of normal digest cycle these expressions are updated and registered as watches.