M
M
Maxla932016-12-18 19:38:12
JavaScript
Maxla93, 2016-12-18 19:38:12

How does JS store function parameters?

Question about storing function data.
1) called the goAcceptOffer_All(888) function
after
2) called the goAcceptOffer_All(999) function
after a few seconds giving newadditems = true.
And data is displayed, but js has one thread, it turns out it should display 2 identical numbers because the same function, but it outputs 888 999, it turns out js stores data in memory for each function call?
It also raises the question of how much data it can store for each function, is there a limit?

var newadditems = false; // По умолчанию

var goAcceptOffer_All = function(data){

     var additems_retry = 40;
        var additemsload = function() {
         additems_retry--;
                 // По умолчанию newadditems = false
      if(newadditems == false){
         // Таймер каждую 1 сек запускает функцию и проверяет не стал ли newadditems = true
        setTimeout(function(){
         console.log('Запустился additems');
         additemsload();
        }, 1000);

         }else if(newadditems == true){ // Выводит данные
       console.log('data: ',data);
      }
     }
     additemsload();
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
amorphine, 2016-12-18
@Maxla93

Closures

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question