MCPcopy Create free account
hub / github.com/dop251/goja / ExampleRuntime_NewArray

Function ExampleRuntime_NewArray

runtime_test.go:2294–2310  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2292}
2293
2294func ExampleRuntime_NewArray() {
2295 vm := New()
2296 array := vm.NewArray(1, 2, true)
2297 vm.Set("array", array)
2298 res, err := vm.RunString(`
2299 var acc = "";
2300 for (var v of array) {
2301 acc += v + " ";
2302 }
2303 acc;
2304 `)
2305 if err != nil {
2306 panic(err)
2307 }
2308 fmt.Println(res)
2309 // Output: 1 2 true
2310}
2311
2312func ExampleRuntime_SetParserOptions() {
2313 vm := New()

Callers

nothing calls this directly

Calls 4

NewFunction · 0.85
NewArrayMethod · 0.80
RunStringMethod · 0.80
SetMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…