javascriptc#.netclassjint

Jint "unexpected reserved word"


I am using the Jint interpreter for C# Jint

I want to run the following JavaScript code.

class User {
  constructor(name) { this.name = name; }
  sayHi() { alert(this.name); }
}
...

But I always get an exception "unexpected reserver word in line 1."

What am I doing wrong?

The c# code looks like this:

Engine jsEngine = new Engine();
jsEngine.Execute(script);

The solution is to build the class like described here.


Solution

  • Jint is a Javascript interpreter for .NET which provides full ECMA 5.1 compliance

    The exception you are seeing is because of the class keyword, it was introduced in ES6 which Jint does not support yet.