diff --git a/internal/jsre/jsre.go b/internal/jsre/jsre.go
index 4813893047ce1517d335ee33d103bdc736bf04c6..17b686c6ae831b23ee34b6401327db75ae4e88e0 100644
--- a/internal/jsre/jsre.go
+++ b/internal/jsre/jsre.go
@@ -71,7 +71,7 @@ func New(assetPath string, output io.Writer) *JSRE {
 	}
 	go re.runEventLoop()
 	re.Set("loadScript", re.loadScript)
-	re.Set("inspect", prettyPrintJS)
+	re.Set("inspect", re.prettyPrintJS)
 	return re
 }
 
diff --git a/internal/jsre/pretty.go b/internal/jsre/pretty.go
index 8fe00cc4c828f1e4b58fd59b5938f5edec7605c6..e096eec2365817fdc2ea452bd56b0ffc9c485c7f 100644
--- a/internal/jsre/pretty.go
+++ b/internal/jsre/pretty.go
@@ -73,10 +73,10 @@ func jsErrorString(err error) string {
 	return err.Error()
 }
 
-func prettyPrintJS(call otto.FunctionCall, w io.Writer) otto.Value {
+func (re *JSRE) prettyPrintJS(call otto.FunctionCall) otto.Value {
 	for _, v := range call.ArgumentList {
-		prettyPrint(call.Otto, v, w)
-		fmt.Fprintln(w)
+		prettyPrint(call.Otto, v, re.output)
+		fmt.Fprintln(re.output)
 	}
 	return otto.UndefinedValue()
 }