This project is read-only.

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 11:06 PM by sebastienros, version 2

Comments

mwawrusch Oct 17, 2010 at 2: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 7:41 AM 
Actually, the semicolon is optional...

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