Home:ALL Converter>Difference between following js code snippets

Difference between following js code snippets

Ask Time:2017-03-03T13:01:07         Author:Kumar Swapnil

Json Formatter

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?

Author:Kumar Swapnil,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/42571022/difference-between-following-js-code-snippets
yy