The for loop right under should throw an error if it's not an iterable anyways, so I'll not do that crazy check
— Is there any way to hide js from page source ?
— Run it on the server
— Server render webpages and then use a socket to unpack code directly in memory
— Also, why would you want to hide JS?
— I've seen people send JS over HTTPS and use eval to run it, but it will still appear in network/sources. If you use a socket you can use some encapsulated protocol to hide the data you are sending/recieving