Using closures in JavaScript to create private variables

Problem statement JavaScript objects are really just a collection of properties. Using either the object literal syntax or a constructor, objects can be created and properties can be added with ease. Here is a code sample: Each of these methods gives us the same result. We have a new object that has firstName and lastName...