Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ahuigo opened this issue Dec 22, 2023 · 3 comments
Open

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

ahuigo opened this issue Dec 22, 2023 · 3 comments

Comments

@ahuigo
Copy link

ahuigo commented Dec 22, 2023

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

@chrislowth
Copy link

chrislowth commented Dec 22, 2023 via email

@Asday
Copy link

Asday commented Dec 22, 2023

Please note that this is in the README also.

@stevenh
Copy link
Collaborator

stevenh commented Dec 22, 2023

PRs to introduce newer features are welcome, would be nice if we could get to ES6 in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants