`let x=1` 和 `const x=1` 不能正常运行。
作者: ahuigo创建于 2023年12月22日更新于 2025年1月31日
标签help wanted
package m
import (
"fmt"
"testing"
"GitHub.com/robertkrimen/otto"
)
func TestEvalJs(t *testing.T) {
vm := otto.New()
vm.Set("body", {"page":1})
v, err := vm.Run( let abc = 2 + 2;// Not work here console.log("The value of abc is " + abc); // 4 )
if err != nil {
fmt.Printf("%+v, val:%v", err, v)
}
}
我发现另一个支持 const/let 的库:https://GitHub.com/dop251/goja
内容来源: robertkrimen/otto