Gmail users trying to send a message will see the attachment is “blocked for security reasons!” as shown in the screenshot above. The reason to block .js files is for security reasons and it joins other file types like .exe, .msc, and .bat.
.js files have their legitimate uses but are maliciously used for spearphishing attacks. My previous organization blocked .js files quite a while ago because the increased frequency of malicious attachments, the rise (again) of Office document macro malware, and the threat of ransomware. It was noted on many security sites that .docx.js files were being sent to spread malware and at that time we blocked the file extension.
If you still need to send a legitimate .js file, you can upload the file to Google Drive or other cloud storage and then send a link to the file to share it.
For a full list of file types that you cannot send to or from Gmail (including if you compress them in .zip files), visit this Google Support page for a current list.