Closures are the primary mechanism used to enable data privacy. When you use closures for data privacy, the enclosed variables are only in scope within the containing (outer) function. It makes it possible for a function to have \\"private\\" variables function myFunction() { var name = \\"Hello world\\"; function displayName () { alert(name); } return displayName; } let myFunc = myFunction(); myFunc(); Here displayName() method is private method, meaning it can't be access directly from outside