var names=["Fred","Wilma","Pebbles"]; var upper=names.map(function(name){ return name.toUpperCase(); }); upper;//["FRED", "WILMA", "PEBBLES"]
var alphabet=""; for(var i=0;i<26;i++){ alphabet+=String.fromCharCode(aIndex+i); } alphabet;//"abcdefghijklmnopqrstuvwxyz"
function buildString(n,callback){ var result=""; for(var i=0;i<n;i++){ result +=callback(i); } return result; }
var alphabet=buildString(26,function(i){ return String.fromCharCode(aIndex+i); }); alphabet;//"abcdefghijklmnopqrstuvwxyz" var digits=buildString(10,function(i){return i;}) digits;//"0123456789"; var random=buildString(8,function(){ return String.fromCharCode(Math.floor(Math.random()*26)+aIndex); }); random;//"awhxtbao"
var table = { entries: [], addEntry: function (key, value) { this.entries.push({ key: key, value: value }); }, forEach: function (f, thisArg) { var entries = this.entries; for (var i = 0, n = entries.length; i < n; i++) { var entry = entries[i]; f.call(thisArg, entry.key, entry.value, i); } } }