Which version of JavaScript for views? And what is builtin?


My Google-fu is weak and I cannot find the answer to the below questions.

What version of Javascript is running the map and reduce functions? Because I have some conditional loops building up an object, I only want to emit it as a value when it actually has properties. This snippet:


will do the job. But keys() is only available in later versions of Javascript.

Hence, which version of Javascript is running in CB v2.1.1 and what subset of browser Javascript does it support?


1 Answer

« Back to question.

Couchbase server uses libv8 to execute javascript.

 $ cat /opt/couchbase/VERSION.txt 
 $ cat /opt/couchbase/lib/libv8.ver 

Then you can get information about this version on github page for this commit:

In this particular case couchbase uses libv8 3.9.7. At this moment debian unstable has Most recent release 3.21.6 (9 hours ago).

Having the version you can google on which version of javascript does this v8 implements.

The answer regarding built-ins:
All of them described in the docs: http://couchbase.com/docs/couchbase-manual-2.0/couchbase-views-writing-u...
Also for reduce you can use special macros instead of reduce function body, which will allow to execute native implementation: http://couchbase.com/docs/couchbase-devguide-2.0/using-built-in-reduces....