Docs Menu

JavaScript Changes in MongoDB 3.2

On this page

  • Modernized JavaScript Implementation (ES6)
  • Changes to the mongo Shell
  • Removed Non-Standard V8 Features

In MongoDB 3.2, the javascript engine used for both the mongo shell and for server-side javascript in mongod changed from V8 to SpiderMonkey.

To confirm which JavaScript engine you are using, you can use either interpreterVersion() method in the mongo shell and the javascriptEngine field in the output of db.serverBuildInfo()

In MongoDB 3.2, this will appear as MozJS-38 and mozjs, respectively.

SpiderMonkey brings with it increased support for features defined in the 6th edition of ECMAScript, abbreviated as ES6. ES6 adds many new language features, including:

MongoDB 3.2 will return JavaScript and BSON undefined values intact if saved into a collection. Previously, the mongo shell would convert undefined values into null.

MongoDB 3.2 also adds the disableJavaScriptJIT parameter to mongod, which allows you to disable the JavaScript engine's JIT acceleration. The mongo shell has a corresponding --disableJavaScriptJIT flag.

SpiderMonkey does not allow the non-standard Error.captureStackTrace() function that prior versions of MongoDB supported. If you must record stack traces, you can capture the Error().stack property as a workaround.

Give Feedback
MongoDB logo
© 2021 MongoDB, Inc.

About

  • Careers
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2021 MongoDB, Inc.