Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is wrapping code into a closure a good habit?

I a new to Angular and I just completed 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

like image 821
Rohan Avatar asked Nov 17 '14 05:11

Rohan


1 Answers

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

like image 117
TGH Avatar answered Oct 10 '22 08:10

TGH