A shorter script with Old Pedant observations
Code:
var arr=[1,41,222,33,41,41,41,40,41,18,41,41,41,22,41,2,2,41,42,27,41,58];
var dominant=null,halfLength=arr.length/2,str=arr.sort().join(',').replace(/(,\d+)(\1+)(?=,)/g,
function(a,b){if (halfLength<=a.length/b.length) {dominant=+b.substr(1)}});
var msg=dominant?'Dominant number : '+dominant:'No dominant number !'
alert(msg);
EDIT : A
new corrections repetition followed by a comma or a word boundary. An assertion like (\1+)(?=,|\b) matches a repetition followed by a comma or a word boundary, but does not include the comma in the match. There is never two dominant numbers !