admin管理员组

文章数量:1297085

I a new to Angular and I just pleted a tutorial from Code School for beginners in Angular. Now in the second video the instructor of the course says that we are going to wrap our whole application code into a closure. The link to the video is below. He says this somewhere at 00:30. Now why is it a good practice to wrap our code into a closure?

Link to the video

I a new to Angular and I just pleted a tutorial from Code School for beginners in Angular. Now in the second video the instructor of the course says that we are going to wrap our whole application code into a closure. The link to the video is below. He says this somewhere at 00:30. Now why is it a good practice to wrap our code into a closure?

Link to the video

Share Improve this question asked Nov 17, 2014 at 5:26 RohanRohan 13.8k23 gold badges87 silver badges159 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 15

Closures are primarily used to create private scope and avoid variables from leaking into the global scope.

本文标签: javascriptIs wrapping code into a closure a good habitStack Overflow