I am new to Javascript and a bit confused about the difference between following code snippets.
Snippet 1:
window.onload = function() {
var friendlyChat = new FriendlyChat();
};
Snippet 2:
window.onload = function() {
window.friendlyChat = new FriendlyChat();
};
Can anyone please tell the difference between them?