Count frequency of words in a string returning list of unique words sorted by frequency in descending order
From a once over:


It seems your code is giving the words with fewest occurrences, consider switching b.count and a.count
I am not vehemently against regexes, but if you use them, I would advise 2 lines of comments, one with the intent of the regex, and one with an example of from -> to
Naming, numofwords -> should be numOfWords or since you only use it once you might as well go for numberOfWords and personally I called it cutOff
Not sure why you named the string myString, I would just call it string or s
It seems that sorting the words in advance will require more code to process the words and it is not guaranteed to be faster, I would not do that
From a data structure perspective, I would go for an object, where each word is a property of the object, and the value is the count, this way you can skip the build 
If you are going to sort and slice, then perhaps you should FIRST sort and SECOND slice ;)


This would be my approach:

function getFrequency2(string, cutOff) {
  var cleanString = string.replace(/[\.,-\/#!$%\^&amp;\*;:{}=\-_`~()]/g,""),
      words = cleanString.split(' '),
      frequencies = {},
      word, frequency, i;

  for( i=0; i&lt;words.length; i++ ) {
    word = words[i];
    frequencies[word] = frequencies[word] || 0;
    frequencies[word]++;
  }
  
  words = Object.keys( frequencies );

  return words.sort(function (a,b) { return frequencies[b] -frequencies[a];}).slice(0,cutOff).toString();
}

document.write( getFrequency2( "1 2 1 2 3 1 2 3 1 1 4 test", 3  ) );