简体   繁体   中英

How do I evaluate JavaScript expressions server-side using .NET Core?

I'm building an expression engine that I want to script using JavaScript. In .NET Framework it was possible to use the JScript library to evaluate JavaScript expressions. However in .NET Core JScript isn't currently supported. Also the existing libraries(NodeServices/SpaServices) have been deprecated. What is the best solution for achieving something like:

    var result = SomeJavaScriptEvaluator.Eval("1 + 1"); //2
    var isConditionTrue = SomeJavaScriptEvaluator.Eval("someValue !== null"); //true or false

So ClearScript provides the answer to this. It is an implementation of the V8 JavaScript engine and provides methods to invoke JavaScript expressions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM