jsToolboxMJK.funcs.invokeArray() - mkloubert/jsToolbox GitHub Wiki

jsToolboxMJK.funcs.invokeArray(func [, args]) method

Invokes a function inside a try-catch block and returns the result as object.

Syntax

$jsTB.funcs.invokeArray(func [, args]);

Parameters

Name Type Description
func Function The function to invoke.
args Array [OPTIONAL] The arguments for the function.

Result

The result object.

Properties

Name Type Description
duration Number The time the invokation needed.
endTime Date The time the invokation finished.
error Object If defined: The error of the invokation.
hasFailed Boolean Gets if the invokation has been failed or not.
result mixed The result of the invokation.
startTime Date The time the invokation started.

Examples

// res.hasFailed = false
var res1 = $jsTB.funcs.invokeArray(function(a, b) {
    // TM+MK
    alert(a + '+' + b);
}, ['TM', 'MK']);

// res.hasFailed = true
var res2 = $jsTB.funcs.invokeArray(function(a, b) {
    // TM+MK
    alert(a + '+' + b + '=' + c);
}, ['TM', 'MK']);