Back to functions

Expression.buildFunction


buildFunction

Generates a JavaScript function given the expression. This is perfect for plotting and filtering user input. Plotting for the demo is accomplished using this. The order of the function parameters is in alphabetical order by default but an array containing the list of arguments in the preferred order can be passed to the function.

Usage: nerdamer(expression).buildFunction(args_array)


Parameters

String[] args_array The argument array with the order in which they are preferred.

Returns

Function

EXAMPLES:
var e = nerdamer('x^2+y');
var f = e.buildFunction();
console.log(f(2, 3));
//change the variable order by passing in an array with the order
var g = e.buildFunction(['y', 'x']);
console.log(g(2, 3));
OUTPUT:
Back to functions