Introduction

vRealize Orchestrator leverages Mozilla Rhino Engine 1.7R4 as its scripting engine and implemented Javascript 5.1 that allows developer to create automation workflows/actions as a collection of Javascript scripts.

However, there are evidences that the JS constructs used in vRO 8.x are not confined to Javascript 5.1, for example, const. Let’s talk about it.

As you notice at Ecma-262 Edition 5.1 website, there is no const keyword.

const keyword was introduced in ES2015 (ES6) to define a new variable.

Looking at it, I can say I am not very sure which version of JavaScript vRO exactly uses, It is probably somewhere in between 5.1 and 6.0 as it doesn’t support all 6.0 features.

Rhino 1.7R4 Const Feature Compatibility Chart

This chart clearly shows that Rhino Engine in vRO only provides a basic support for const. However, we will do some tests to validate it.

Source: https://mozilla.github.io/rhino/compat/engines.html

What is const?

const or Constants are block-scoped variables declared using the const keyword. The value of a constant can’t be changed through reassignment (i.e. by using the assignment operator), and it can’t be redeclared (i.e. through a variable declaration). However, if a constant is an object or array its properties or items can be updated or removed.

Typical Properties of a const

  • Cannot be reassigned
  • Block Scope
  • It can be assign on the variable on declaration line.
  • Primitive value.
  • The property of a const object can be change but it cannot be change to reference to the new object
  • The values inside the const array can be change, it can add new items to const arrays but it cannot reference to a new array.
  • Re-declaring of a const variable inside different block scope is allowed.
  • Cannot be Hoisted.
  • Create only read only reference to value.

How does a vRO const differ?

Now, I have also realized that even if const is supported in vRO, it doesn’t behave exactly like the normal const. So, I have done some testing by executing the same code in vRO 8.3 and on the Mozilla website here and compared the results. Let’s see which use-case passed the test and which one failed.

Test Results

Error: Assignment to constant variable [FAIL]


Object.freeze() [PASS]*

* vRO does freeze the Object but no TypeError

Name-sharing with f(), variable or other const in the same scope [PASS]


const needs to be initialized [FAIL]


const in objects and arrays [FAIL]


const in for-in loop [FAIL]


With all these outcomes, it’s clear that vRO JS Engine is a totally different entity and it has its own set of rules. We just have to find them. If you like this article, feel free to share and comment. See you on other posts.

Suggestive Readings

  1. Javascript Limitations in vRealize Orchestrator 8.6 by Joey Kleinsorge
  2. JavaScript ES6+: var, let, or const? by Eric Elliott

References