Open ahuigo opened 8 months ago
Otto is an implementation of ECMA standard version ES5. "let" and "const" are not part of that standard. They were introduced in ES6.
You should use "var" instead.
On Fri, 22 Dec 2023, 04:09 Ahuigo, @.***> wrote:
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) } }— Reply to this email directly, view it on GitHub https://github.com/robertkrimen/otto/issues/515, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH2YHJJGJ6NK4IYEGGVF72LYKUBVRAVCNFSM6AAAAABA7JR6E6VHI2DSMVQWIX3LMV43ASLTON2WKOZSGA2TGMZVGI4TSMY . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Please note that this is in the README also.
PRs to introduce newer features are welcome, would be nice if we could get to ES6 in the future.
I find another lib which supports
const
/let
: https://github.com/dop251/goja