Consider the following straightforward example.
(function() {
var message = {
display: function() {
alert('hello');
}
};
})();
When trying to implement
message.display();
An error is triggered stating
ReferenceError: message is not defined
.
However, using the message object without being enclosed by an anonymous function works just fine.
So, how can I utilize the message object outside of the anonymous function or on another page?