Posts Tagged ‘Best Practices’





Use Windows Grep is to search the contents of one or more files on your PC for occurrences of text strings you specify and display the results. Once found, it can replace matches with other strings.





Refer following links in your web pages to get latest version of JQuery files from CDN …

Do you know how to use Firebug’s console effectively?

Execute jQuery/javascript statement at the console, with your page loaded in the browser, and you will instantly see the array of matching elements that are returned. If that result set isn’t correct, press the up-arrow key to retrieve the last command entered, refine the statement, and test it again

It works in conjunction with Firebug’s debugger. When execution is paused, switching to the console tab allows you to interrogate and manipulate the state of the DOM as it was at the time execution was halted. As you step through JavaScript code in the debugger, the execution context of the console remains in sync with the debugger’s.

// 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];

// 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

return words[n];

// 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

return function (n) {
return words[n];
} ();