Skip to content

JavaScript Function Semantics

All the functions that Volt MX API accepts and returns should be valid JavaScript Function with all the semantics with the exceptions mentioned in the section.

This section covers the following topics:

Nested Functions and Closures

Nested functions and closures are allowed as it is first class feature of the JavaScript language. Every function in JavaScript can be closure and can have nested functions as required.

The following URL will help in the understanding of closures and nested functions:

Functions that contain the nested functions can be passed to the Volt MX Iris APIs (as a callback to the events) and the underlying platforms use the ECAM-262 v3 compatible engine to execute the functions. Closures can also be passed to the Volt MX Iris APIs (as a callback to the events.

length function

Function should support the length function which indicates the number of arguments that it takes. Following code fragments explain how to access the length property:

var f = function(x) {};  
f.length // returns 1

arguments.callee.length is another way of accessing the expected number of arguments for the function.

function checkArgs(x,y,z)  
     var actual_passed_args = arguments.length;  
     var expected_args = arguments.callee.length;  
     if(actual_passed_args != expected_args)  
          //do something  

The apply( ) and call( ) Methods

Every JavaScript function will have apply and call methods which can be used to invoke the functions with arguments dynamically and also passing the context (this) in which the function to be executed. JavaScript

Note: Objects that Volt MX API creates and returns can be passed as context or one of the arguments. Functions exposed by the Volt MX Iris APIs cannot be invoked through apply and call methods.