P
P
Peter2015-03-25 21:50:01
JavaScript
Peter, 2015-03-25 21:50:01

Simultaneous access to javascript variable?

Hello. I am using angular.js. I have this situation:
- there are several directives on the page that generate some content
- directives in the view go in a certain order
- after loading the directive, or rather executing the link method, I increase the variable in the parent scope (that is, in the scope of the controller) by 1, in fact, I keep a counter of loaded directives.
Is it possible that two directives can change the value of this variable at the same time? And one increase is lost. Does javascript have some sort of mutex type locking mechanism for accessing a variable?
Angular has just started learning, so maybe the question is not quite correct and not in full accordance with angular terminology
Thanks for the answers

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lega, 2015-03-25
@lega

It will not be lost, the code is executed in one thread in turn.
PS: you can also look at Angular Light if you don't like the original.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question