Site by Peter-Paul Koch – A prime source to check browser compatibility information. We will find here the free assessments of the major browsers’ CSS and JavaScript capabilities, as well as their adherence to the W3C standards

// Global Variables – Version 1 : Should not use as the variable names may clash with other libraries that we refer in the page
var words = [‘a1’, ‘b1’, ‘c1’];
var getWord1 = function (n) {
return words[n];
};
alert(getWord1(1));

// Global Variables – Version 2 (better version ): but it is slow due to the fact that words array is recreated everytime we call getWord2 function
var getWord2 = function (n) {
var words = [‘a2’, ‘b2’, ‘c2’];
// Everytime getWord2 is called words array gets recreated, for testing you can have alert below and see that alert will be displayed on every getWord2 method call
alert(“getWord2”);

return words[n];
};
alert(getWord2(0));
alert(getWord2(1));

// Global Variables – Version 3 (best version) : using Closure
var getWord3 = function () {
var words = [‘a3’, ‘b3’, ‘c3’];
// Everytime getWord3 is called words array will not be recreated, for testing you can have alert below and see that alert will not be displayed on every getWord3 method call
alert(“getWord3”);