Few tips on JavaScript – Part II

This blog is a continuation of my last posting.

Solve the pass by reference problem in JavaScript
Many of us has come across the pass by reference problem in JavaScript array. we have simply assign one array to another array and any modification in one array reflects both the arrays and we bang our head where it is got changed.

var myArray=["test","nice","great"];
var changedArray=myArray;
changedArray[1]="chnagedValue";
console.log(myArray);
console.log(changedArray);

Continue reading

Advertisements

Few tips on JavaScript – Part I

Properties in double quotes

var myArray=["test","xyz","great"];
console.log("MyArray Length (Without Quotes)="+myArray.length);
console.log("MyArray Length (With Quotes)="+myArray["length"]);

Output
MyArray Length (Without Quotes)=3
MyArray Length (With Quotes)=3

Description
As we know that we can access Array properties by array name with dot notation. But we also can access the array properties through the array square bracket within the quote. The array operator (square brackets) is also used for accessing the array’s properties (arrays are also objects in JavaScript) .So we can access the array length property within the quotes in the array square bracket. Continue reading

Smooth Page Transition on Mobile Devices within Single HTML Page

While exploring the CSS3 transitions and animations, I found them much helpful for the smooth page transitions for mobile devices. Let’s see how can we achieve this.

Basic HTML: This is the basic html that will hold the divs that will act like a page. So all the pages are finally rendered into this container.

<body>
<div id=”mainContainer”></div>
</body>

Templates Used: These templates are loaded when you click on the links to navigate between pages.

Continue reading