Skip to content

let x=1 and const x=1 don't work. #515

@ahuigo

Description

@ahuigo
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)
	}
}

I find another lib which supports const/let: https://github.com/dop251/goja

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions