I’m interested if there is any function like array_map or array_walk from php.
Don’t need an for that travels all the array. I can do that for myself.
var array = ['dom', 'lun', 'mar', 'mer', 'gio', 'ven', 'sab'];
// i would like something like this if exists - function(array, 'upperCase');
You can use $.map() in order to apply String.toUpperCase() (or String.toLocaleUpperCase(), if appropriate) to your array items:
Note that
$.map()builds a new array. If you want to modify your existing array in-place, you can use $.each() with an anonymous function:Update: As afanasy rightfully points out in the comments below, mapping
String.toUpperCasedirectly will only work in Gecko-based browsers.To support the other browsers, you can provide your own function: