const obj = { a: 1, b: 2 }
const keys = Object.getOwnPropertyNames(obj)
keys.forEach(console.log)
(function endWorld() { console.log("Wat") })()
keys.forEach executes, outputting the keys to the log, and then the last line throws an error saying keys.forEach is not a function.
I could work around this but I really want to know why it's happening.