Returning values

Scripts can return values to the host application. The return keywords is used for this purpose.

JintEngine engine = new JintEngine();
var result = engine.Run("return 0;");
Console.WriteLine(result); // Displays 0

Also, if a statement is evaluated, the return value will be the value of this statement:

Console.WriteLine(engine.Run("var a = true;")); // Displays true

Last edited May 10, 2011 at 10:06 PM by sebastienros, version 2


mwawrusch Oct 17, 2010 at 1:57 PM 
Technically it is not be an error, but very bad style, and a lot of fun when you minify scripts that contain missing semicolons.

janus03 Jul 22, 2010 at 6:41 AM 
Actually, the semicolon is optional...

GWBasic Nov 12, 2009 at 11:19 PM 
The above code has a Javascript error, it's missing a semicolon. It needs to be Run("return 0;");