Questions tagged as 'closures'

2
answers

closure inside a loop

I have the following code, I do not understand the result var funcs = []; for (var i = 0; i < 3; i++) { funcs[i] = function() { console.log("el valor: " + i); }; } for (var j = 0; j < 3; j++) { fun...
asked by 30.12.2016 / 06:19
2
answers

Use data returned by $ http in the AngularJS driver

My problem is that I make a request for $http to recover some data that I need to use in my controller, the problem is that if I make a console.log out with the variable assigned to the data it marks undefined . I wanted t...
asked by 14.01.2017 / 12:31
1
answer

Javascript: Example with Scope and Closures

I was looking for information about Scope and Closures, and I thought I had already understood it, when I see this example on the page that was the information: let a = 1; const function1 = function() { console.log(a); a = 2; }; a = 3;...
asked by 15.07.2018 / 07:04
1
answer

Javascript closure in for loop

What I want is to go through the matrix material and generate a div for each element and that in the first div put elemento1 , in the second elemento2 etc. This is what I have: var material = [{nombre: 'elemento1'},{nomb...
asked by 21.03.2017 / 14:20