For a not relevant reason for this question, i need to call a javascript function, defined inside a js file, from a .net desktop application and get the result.
I'm using Jurassic to do this. However i don't know how to call functions which recieve complex types. Is more simple to explain using an example.
I have this js file
function plus(a, b) {
return a + b;
}
Then, for call this function on .net, i use this code:
Dim auxfile As New Jurassic.FileScriptSource(pathToPreviosJSFile)
Dim aux As New Jurassic.ScriptEngine
aux.Evaluate(auxfile)
Dim suma As Integer = aux.Evaluate("plus(2,3)")
At this point suma = 5. However if the definition of plus function was
function plus(a, b) {
return a.value + b.value;
}
How should i call plus function to get the same result?
you are calling value property of
a
andb
means a and b are objects. so you can call that function as