Dive into Android development – V
arguments in JavaScript
function concat(){
var result = “”;
for(var i=0;i<arguments.length;i++){
result += arguments[i] + ” “;
}
return result;
}
document.write(concat(“This”,”is”,”cool”)); //Output is This is cool
if(typeof arguments[i] == ‘string’)
result += arguments[i] + ” “;
But what is strange is that the ‘arguments’ is really not an Array instance in the true sense. It doesn’t have methods like slice, push, pop associated with the Array class. So need to be a bit careful while using ‘arguments’.
extraParams in Ext JS 4
var cityStore = Ext.create(“Ext.data.Store”,{
fields : [“name”],
autoLoad : false,
proxy : {
type : “ajax”,
url : “citiesServlet”,
reader : { type : “json”}
}
}});
The cityStore is populated by sending a request to a ‘citiesServlet’. The city combo box can be mapped to the cityStore. The country and city combo boxes are declared as shown below.
{
xtype : “combo”,
displayField : “name”,
fieldLabel : “Country”,
store : {
fields : [“name”],
data : [
{name:”India”},{name:”UK”},{name:”USA”}
]
},
listeners : {
change : function(source,newValue,oldValue){
cityStore.proxy.extraParams = {“country” : newValue};
cityStore.load();
},
}
},
{
xtype : “combo”,
store : cityStore,
displayField : “name”,
fieldLabel : “City”
}
Dive into Android Development – IV