What happens if I define a .Net class in JavaScript code using Jint engine

Viewed 1124

In Jint, you can access .Net classes in JS.

JS File Code :

var write = function (msg) {

    var log = System.Console.WriteLine;
    log(msg);
};

C# Code

 Engine jsEngine = new Engine(e=>e.AllowClr());
 string script = System.IO.File.ReadAllText("file1.js");
 jsEngine.Execute(script);
 jsEngine.Invoke("write", "Hello World!");  //Displays in Console: "Hello World!"
  • I can't understand what happens in background? Which compiler will compile the injected c# code in JS file? C# Compiler or JS?
  • If I declared C# List in JS file, Is the generated object JS object or C# object?
2 Answers
Related