Why is Javascript used in MongoDB and CouchDB instead of other languages such as Java, C++?
<p>I asked this question on SO but was suggested to try here. So here it goes:</p>

<p>My understanding of Javascript so far has been that it is a client-side language that capture events and makes a web-page dynamic.</p>

<p>But on reading the <a href="http://www.mongodb.org/display/DOCS/Comparing+Mongo+DB+and+Couch+DB">comparison between MongoDB and CouchDB</a> I noticed that both are using Javascript. This makes me wonder the reason behind the choice of JavaScript over other conventional languages.</p>

<p>I guess I am trying to understand the role of JavaScript and its advantages over other languages.</p>

<p>Update: I am not asking about the languages / drivers supported by the two databases. The comparison says: </p>

<blockquote>
  <p>Both CouchDB and MongoDB make use of Javascript. CouchDB uses Javascript extensively including in the building of <a href="http://wiki.apache.org/couchdb/Introduction_to_CouchDB_views">views</a>.</p>
  
  <p>MongoDB also supports running arbitrary javascript functions server-side and uses javascript for map/reduce operations.</p>
</blockquote>

<p>My lack of understanding pertains to why is Javascript being used at all for the backend work. Why is it preferred for building views in CouchDB, or for using map/reduce operations? Why C/C++ or Java were not used? What are the advantages in using Javascript for such back-end work?</p>
