dojo.indexOf lets you easily determine the index of an element in an array. It locates the first index of the provided value in the passed array. If the value is not found, -1 is returned.

<scripttype="text/javascript">// this Button is just to make the demo look nicer:dojo.require("dijit.form.Button");vararrIndxOf=["foo","hoo","zoo"];functiontestIndxOf(){varposition=dojo.indexOf(arrIndxOf,"zoo");dojo.place("<p>The index of the word 'zoo' within the array is "+position+"</p>","result1","after");}</script>

<div>The content of our test array is ["foo", "hoo", "zoo"].</div><buttonid="refButton1"dojoType="dijit.form.Button"onClick="testIndxOf()"type="button">Show the index of the word 'zoo' within the array.</button><divid="result1"></div>

dojo.lastIndexOf lets you easily determine the last index of an element in an array. It locates the last index of the provided value in the passed array. If the value is not found, -1 is returned.

Note: Calling indexOf with the findLast parameter set to true is the same as calling lastIndexOf.

<scripttype="text/javascript">// this Button is just to make the demo look nicer:dojo.require("dijit.form.Button");vararrLastIndxOf=["foo","hoo","zoo","shoe","zoo","nuu"];functiontestLastIndxOf(){varposition=dojo.lastIndexOf(arrLastIndxOf,"zoo");dojo.place("<p>The last index of the word 'zoo' within the array is "+position+"</p>","result2","after");}</script>

<div>The content of our test array is ["foo", "hoo", "zoo", "shoe", "zoo", "nuu"].</div><buttonid="refButton2"dojoType="dijit.form.Button"onClick="testLastIndxOf()"type="button">Show the last index of the word 'zoo' within the array.</button><divid="result2"></div>

This is a heavylifter you will use a lot when writing your apps using Dojo. dojo.forEach lets you iterate over arrays, node lists and provides you with ways to filter your results. Lets take a look at a very basic example.
Note the "i" variable which returns the current position of an iteration

<scripttype="text/javascript">dojo.require("dijit.form.Button");// this is just to make the demo look nicervararrFruit=["apples","kiwis","pineapples"];functionpopulateData(){dojo.forEach(arrFruit,function(item,i){varli=dojo.doc.createElement("li");li.innerHTML=i+1+". "+item;dojo.byId("forEach-items").appendChild(li);});}</script>

Now lets use dojo.forEach with a list of dom nodes we retrieve using dojo.query. Note that dojo.query returns the list of dom nodes as an array. This way you can easily iterate over each dom node using dojo.forEach

<scripttype="text/javascript">dojo.require("dijit.form.Button");// this is just to make the demo look nicervararr=["apples","kiwis","pineapples"];functionpopulateQueryData(){dojo.query("li").forEach(function(item,i){varli=dojo.doc.createElement("li");li.innerHTML=i+1+". "+item.innerHTML;dojo.byId("forEachQuery-items").appendChild(li);});}</script>

There are many cases when you have an array and want to filter it by a certain condition, say you have an array of people with a last name. You would like to filter those having a certain last name. Lets take a look at anexample

<scripttype="text/javascript">dojo.require("dijit.form.Button");// this is just to make the demo look nicervararr=[{surname:"Washington",name:"Paul"},{surname:"Gordon",name:"Amie"},{surname:"Meyer",name:"Sofie"},{surname:"Jaysons",name:"Josh"},{surname:"Washington",name:"George"},{surname:"Doormat",name:"Amber"},{surname:"Smith",name:"Susan"},{surname:"Hill",name:"Strawberry"},{surname:"Washington",name:"Dan"},{surname:"Dojo",name:"Master"}];functionfilterArray(){varfilteredArr=dojo.filter(arr,function(item){returnitem.surname=="Washington";});dojo.forEach(filteredArr,function(item,i){varli=dojo.doc.createElement("li");li.innerHTML=i+1+". "+item.surname+", "+item.name;dojo.byId("filtered-items").appendChild(li);});dojo.forEach(arr,function(item,i){varli=dojo.doc.createElement("li");li.innerHTML=i+1+". "+item.surname+", "+item.name;dojo.byId("unFiltered-items").appendChild(li);});}</script>

Another great function provided by Dojo is dojo.map. dojo.map lets you run a function on all elements of an array and returns a new array with the changed values. A very good example is the "Give all my employees a 10% salary rise":

<scripttype="text/javascript">dojo.require("dijit.form.Button");// this is just to make the demo look nicervararrSalary=[200,300,1500,5,4500];functionraiseSalary(){varraisedSalaries=dojo.map(arrSalary,function(item){returnitem+(item/100)*10;});dojo.forEach(raisedSalaries,function(item,i){varli=dojo.doc.createElement("li");li.innerHTML=i+1+". New salary: "+item;dojo.byId("filteredSalary-items").appendChild(li);});dojo.forEach(arrSalary,function(item,i){varli=dojo.doc.createElement("li");li.innerHTML=i+1+". Old salary: "+item;dojo.byId("unFilteredSalary-items").appendChild(li);});}</script>

Imagine you are a manager of a famous bank. A client of you comes and visits your office asking for another million dollars as a credit.
Now your bank policies only allows you to give each client one credit over 1 million, not two, not three - though you may have several smaller credits. Even 3 credits a 500.000 - weird bank.. anyways. dojo.some is the perfect function to tell you whether an array has some of the asked values:

<scripttype="text/javascript">// this Button is just to make the demo look nicer:dojo.require("dijit.form.Button");vararrIndxSome=[200000,500000,350000,1000000,75,3];functiontestIndxSome(){if(dojo.some(arrIndxSome,function(item){returnitem>=1000000})){result='yes, there are';}else{result='no, there aren no such items';}dojo.place("<p>The answer is: "+result+"</p>","result6","after");}</script>

<div>The content of our test array is [200000, 500000, 350000, 1000000, 75, 3].</div><buttonid="refButton6"dojoType="dijit.form.Button"onClick="testIndxSome()"type="button">Are there some items >=1000000 within the array?</button><divid="result6"></div>

Lets get back to our bank manager. A client wants another credit, but you only allow a credit if every income transfer is at least 3000,-
An example:

<scripttype="text/javascript">// this Button is just to make the demo look nicer:dojo.require("dijit.form.Button");vararrIndxEvery=[{'month':'january','income':2000},{'month':'february','income':3200},{'month':'march','income':2100}];functiontestIndxSome(){if(dojo.every(arrIndxEvery,function(item){returnitem.income>=3000})){result='yes, he is allowed';}else{result='no, unfortunately not';}dojo.place("<p>The answer is: "+result+"</p>","result7","after");}</script>