Your scripts are probably loading out of order or your createTable definition is somehow deferred, so at the time you define the listener for load, createTable is still undefined. The easiest way to fix the former to simply ensure that the script containing createTable is encountered before adding the event listener, see this question for more information.
If your createTable definition is happening later for some reason, or just as an alternative, as long as you're sure it'll be defined when the listener runs then you can wrap it in an anonymous function to avoid this unnecessary load-order dependency:
window.addEventListener("load", () => createTable(), false);
window.createTable = () => console.log("hi");
Compare this to something of a similar fashion to your current code, where createTable is likely being defined later:
window.addEventListener("load", createTable, false);
window.createTable = () => console.log("bye");