9.3. JavaScript development tips — Apache CouchDB 2.2 Documentation

# 9.3. JavaScript development tips

Working with Apache CouchDB’s JavaScript environment is a lot different than working with traditional JavaScript development environments. Here are some tips and tricks that will ease the difficulty.

- Remember that CouchDB’s JavaScript engine is old, only supporting the ECMA-262 5th edition (“ES5”) of the language. ES6/2015 and newer constructs cannot be used.

- The `log()` function will log output to the CouchDB log file or stream. You can log strings, objects, and arrays directly, without first converting to JSON. Use this in conjunction with a local CouchDB instance for best results.

- Be sure to guard all document accesses to avoid exceptions when fields or subfields are missing: `if (doc && doc.myarray && doc.myarray.length)...`