JavaScript paling sering dalam daftar

function findMostFrequent(arr) {
	var repsCount = {};
	for (i = 0; i < arr.length; i++) {
		if (!repsCount[arr[i]]) {
			repsCount[arr[i]] = 1;
		} else {
			repsCount[arr[i]] = repsCount[arr[i]] + 1;
		}
	}
	var occursMore = [];
	for (var key in repsCount) {
		if (repsCount[key] > occursMore) {
			occursMore.push(key);
		}
	}
	return occursMore;
}
Fierce Ferret