Writing to companion's javascript console

Hello. Why would you want to do that? That is not possible. But you have a better option, i.e. the Debug Panel:

Logs are also sent over WebRTC to the IDE.

Check out Notifier's LogInfo block:

    if (form.isRepl()) {
      RetValManager.appendLogValue(message, "Notifier", "OK", "Info");
    }