When you ask about the viability of server-side javascript, you first need to clarify which server-side javascript you are talking about. According to the documentation, there are four different options for executing server code. Unfortunately, all of them are hacker workarounds for situations when the native API is not enough:
eval has the disadvantage that it only works on one node. This greatly reduces its usefulness in a cluster environment. With private collections, this does not work!
By default, it also creates a global lock, which makes the database completely unusable until the script is run. This can be prevented with the nolock argument (unless the script does something that creates a global lock).
Sammaye's answer also explains some serious security concerns.
This is more of a testing and administration tool than what you should use for any regular operation.
Running .js files through mongo shell Instance on server
In this case, the code is not executed in the database, but rather on another independent process on one of the servers. This means that all the required data from other shards must be transferred to the server that runs the javascript code, regardless of what really returned with the script.
It appears as another application for the mongodb server, so it cannot do anything that you could not do from your regular application. This is another test and administration tool that you should not use in your normal work.
The $ where operator in the find command allows you to pass a javascript function that is used to filter values. For most trivial cases, this is much less than what other search query tools can offer, especially because it cannot use any indexes.
When using $, where you cannot avoid, at least try to use some of the usual search-query tools to reduce the number of documents that need to be passed to the $ where function.
MapReduce uses two javascript functions to create aggregated data. It used to be the main data mining tool for MongoDB, but most of its usual use cases are now performed by a much more friendly aggregation structure .
It also has the same drawback as $ where: If you are not filtering, you will have to run not one, but at least two javascript functions for each document.
But MapReduce can at least run distributed and can be parallelized.
TL; dr:
Using Javascript is the latest measure for very unusual queries that cannot be done with the normal query language and that require access to too much data that will be implemented in the application. Whenever possible, do what you want to do with the specialized tools you have, or implement your logic at the application level.