Javascript for loop Example

Javascript for loop Example



for(var i=0; i<=10; i++){
    alert("Counter is at "+i);
}

What to note??
From java only a small but confusing difference :

In Javascript it is :

for(var i=0;

Where as in java it is something like for(int i=0; ......... Being a java developer you will be tempted to use int i instead of a var declaration..

Example..

for(var i=0; i<=arr.length; i++){
var property = arr[i].split("=");
var propertyName = property[0];
var propertyVal = property[1];
        //... continue custom logic
 }

Share this

Related Posts

Previous
Next Post »