Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
Back to tool/Back to issues
#513·otto

Value of json expression is `undefined`

Author: kennethkleeCreated Dec 12, 2023Updated Dec 13, 2023

When running this, value, _ = vm.Run("{}"), the resultant value is undefined instead of an Object.

Other types work:

value, _ = vm.Run("1")
// value.toString() is 1
value, _ = vm.Run("true")
// value.toString() is true
value, _ = vm.Run("[1, 2, 3]")
// value.toString() is 1, 2, 3

As an extension, an error is returned when using { "a": 1 }. Error: (anonymous): Line 1:5 Unexpected token :

Source: robertkrimen/otto

View original on GitHubView discussion on GitHub