You can use heredocs to populate the contents of a file in a bash script. Remember you'll have to escape any special characters such as $.
$
❯ cat > script.js << EOF \$(function() { console.log('Hello'); }); EOF