如果对应关系是确定的, 可以
var newAdd = {}var arr = ['张三','北京市二环路XXX','10086','北京市','北京','海淀区','二环内']
var Keys = 'name address tel pro city section range'.split(' '),F
for (F = 0F < Keys.length++F) newAdd[Keys[F]] = arr[F]
如果是要按照newAdd的键写的顺序来, 就
var newAdd = {name:null,address:null,tel:null,pro:null,city:null,section:null,range:null}var arr = ['张三','北京市二环路XXX','10086','北京市','北京','海淀区','二环内']
var K,F = -1
for (K in newAdd) newAdd[K] = arr[++F]
但後者不稳定, 虽然在大部分JS运行环境都没问题
var reverse = function(strIn,pos,strOut){if(pos<0)
return
strOut+=strIn.charAt(pos--)
reverse(strIn,pos,strOut)
}
var in='abcdef'
var out=''
var pos=in.length-1
reverse(in,pos,out)
document.write(out)